diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-21 12:33:49 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-21 12:33:49 +0300 |
commit | edbb99192eba9fe8d4630214b7aff1d35a3066a0 (patch) | |
tree | 960ac9c455ebcb01643e10bf6b6db6fd2426ad04 /lib/Controller/PushController.php | |
parent | 6a4c8af6f8fc9578f3ac10b5f700114ad8a63f78 (diff) |
Add unit tests for the PushController
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/PushController.php')
-rw-r--r-- | lib/Controller/PushController.php | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/Controller/PushController.php b/lib/Controller/PushController.php index 1b4de72..aef6eb3 100644 --- a/lib/Controller/PushController.php +++ b/lib/Controller/PushController.php @@ -99,11 +99,7 @@ class PushController extends OCSController { if ( !filter_var($proxyServer, FILTER_VALIDATE_URL) || strlen($proxyServer) > 256 || - ( - strpos($proxyServer, 'https://') !== 0 && - strpos($proxyServer, 'http://localhost:') !== 0 && - strpos($proxyServer, 'http://localhost/') !== 0 - ) + !preg_match('/^(https\:\/\/|http\:\/\/localhost(\:[0-9]{0,5})?\/)/', $proxyServer) ) { return new DataResponse(['message' => 'INVALID_PROXY_SERVER'], Http::STATUS_BAD_REQUEST); } @@ -141,9 +137,9 @@ class PushController extends OCSController { return new DataResponse([], Http::STATUS_UNAUTHORIZED); } - $sessionId = $this->session->getId(); + $tokenId = $this->session->get('token-id'); try { - $token = $this->tokenProvider->getToken($sessionId); + $token = $this->tokenProvider->getTokenById($tokenId); } catch (InvalidTokenException $e) { return new DataResponse(['message' => 'INVALID_SESSION_TOKEN'], Http::STATUS_BAD_REQUEST); } |