Browse Source

Fix broken tests

Maurits van der Schee 6 years ago
parent
commit
b1efe1d7d0

+ 3
- 1
src/Tqdev/PhpCrudApi/Middleware/BasicAuthMiddleware.php View File

90
             if (!$validUser) {
90
             if (!$validUser) {
91
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
91
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
92
             }
92
             }
93
-            session_regenerate_id();
93
+            if (!headers_sent()) {
94
+                session_regenerate_id();
95
+            }
94
         }
96
         }
95
         if (!isset($_SESSION['username']) || !$_SESSION['username']) {
97
         if (!isset($_SESSION['username']) || !$_SESSION['username']) {
96
             $authenticationMode = $this->getProperty('mode', 'required');
98
             $authenticationMode = $this->getProperty('mode', 'required');

+ 3
- 1
src/Tqdev/PhpCrudApi/Middleware/JwtAuthMiddleware.php View File

107
             if (empty($claims)) {
107
             if (empty($claims)) {
108
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, 'JWT');
108
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, 'JWT');
109
             }
109
             }
110
-            session_regenerate_id();
110
+            if (!headers_sent()) {
111
+                session_regenerate_id();
112
+            }
111
         }
113
         }
112
         if (empty($_SESSION['claims'])) {
114
         if (empty($_SESSION['claims'])) {
113
             $authenticationMode = $this->getProperty('mode', 'required');
115
             $authenticationMode = $this->getProperty('mode', 'required');

+ 2
- 2
tests/functional/002_auth/001_jwt_auth.log View File

1
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
1
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
2
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
2
+X-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
3
 ===
3
 ===
4
 200
4
 200
5
 Content-Type: application/json
5
 Content-Type: application/json
16
 {"id":"e42c77c6-06a4-4502-816c-d112c7142e6d"}
16
 {"id":"e42c77c6-06a4-4502-816c-d112c7142e6d"}
17
 ===
17
 ===
18
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
18
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
19
-Authorization: Bearer invalid
19
+X-Authorization: Bearer invalid
20
 ===
20
 ===
21
 403
21
 403
22
 Content-Type: application/json
22
 Content-Type: application/json

Loading…
Cancel
Save