Browse Source

Migration to PHP 7.x

* updated dependencies
* updated LV version to 5.6

Depends-On: https://review.openstack.org/629495

Depends-On: https://review.openstack.org/629896

Change-Id: Iacf81dd65d71102ad0660c5c2bdd6633bf727ec0
tags/2.0.0
smarcet 7 months ago
parent
commit
cb3fee441f
77 changed files with 931 additions and 407 deletions
  1. 2
    1
      .gitignore
  2. 7
    1
      app/Http/Controllers/Api/ApiEndpointController.php
  3. 1
    1
      app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php
  4. 1
    3
      app/Http/Controllers/Controller.php
  5. 1
    1
      app/Http/Controllers/OAuth2/OAuth2ProviderController.php
  6. 44
    34
      app/Http/Controllers/UserController.php
  7. 2
    4
      app/Http/Middleware/CORSMiddleware.php
  8. 17
    0
      app/Http/Middleware/CheckForMaintenanceMode.php
  9. 2
    2
      app/Http/Middleware/CurrentUserCanEditOAuth2Client.php
  10. 2
    2
      app/Http/Middleware/CurrentUserCheckRouteParams.php
  11. 2
    2
      app/Http/Middleware/CurrentUserOwnsOAuth2Client.php
  12. 25
    7
      app/Http/Middleware/EncryptCookies.php
  13. 2
    3
      app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php
  14. 1
    3
      app/Http/Middleware/RedirectIfAuthenticated.php
  15. 18
    0
      app/Http/Middleware/TrimStrings.php
  16. 23
    0
      app/Http/Middleware/TrustProxies.php
  17. 2
    2
      app/Http/Middleware/VerifyCsrfToken.php
  18. 2
    2
      app/Models/OAuth2/ServerPrivateKey.php
  19. 4
    5
      app/Providers/AppServiceProvider.php
  20. 2
    3
      app/Providers/AuthServiceProvider.php
  21. 3
    5
      app/Providers/EventServiceProvider.php
  22. 2
    2
      app/Providers/RouteServiceProvider.php
  23. 12
    3
      app/Services/OAuth2/ApiEndpointService.php
  24. 5
    2
      app/Services/OAuth2/HttpIClientJWKSetReader.php
  25. 2
    2
      app/Services/OAuth2/PrincipalService.php
  26. 3
    3
      app/Services/OAuth2/ServerPrivateKeyService.php
  27. 0
    1
      app/Services/OpenId/OpenIdMementoSessionSerializerService.php
  28. 1
    1
      app/Services/OpenId/TrustedSitesService.php
  29. 2
    4
      app/Services/Utils/UtilsProvider.php
  30. 10
    10
      app/Validators/CustomValidator.php
  31. 3
    3
      app/libs/Auth/AuthService.php
  32. 2
    3
      app/libs/OAuth2/GrantTypes/InteractiveGrantType.php
  33. 6
    0
      app/libs/OAuth2/Services/IApiEndpointService.php
  34. 45
    0
      app/libs/Utils/RequestUtils.php
  35. 4
    2
      artisan
  36. 12
    19
      bindep.txt
  37. 89
    66
      composer.json
  38. 0
    15
      config/app.php
  39. 52
    0
      config/hashing.php
  40. 81
    0
      config/logging.php
  41. 17
    0
      config/session.php
  42. 23
    0
      database/factories/UserFactory.php
  43. 21
    12
      package-lock.json
  44. 1
    1
      phpunit.xml
  45. 1
    1
      public/assets/js/oauth2/profile/admin/server-private-keys.js
  46. 1
    1
      public/assets/js/oauth2/profile/edit-client-public-keys.js
  47. 1
    1
      server.php
  48. 16
    3
      tests/ApiEndpointTest.php
  49. 14
    18
      tests/ApiScopeTest.php
  50. 15
    3
      tests/ApiTest.php
  51. 17
    8
      tests/AssociationServiceTest.php
  52. 54
    0
      tests/BrowserKitTestCase.php
  53. 15
    1
      tests/CacheServiceStub.php
  54. 1
    3
      tests/ClientApiTest.php
  55. 1
    3
      tests/ClientPublicKeyApiTest.php
  56. 34
    0
      tests/CreatesApplication.php
  57. 1
    1
      tests/CustomAuthProviderTest.php
  58. 13
    2
      tests/DiffieHellmanTest.php
  59. 17
    2
      tests/DiscoveryControllerTest.php
  60. 21
    0
      tests/Feature/ExampleTest.php
  61. 1
    3
      tests/OAuth2ProtectedApiTest.php
  62. 18
    18
      tests/OAuth2ProtocolTest.php
  63. 13
    3
      tests/OAuth2UserServiceApiTest.php
  64. 2
    4
      tests/OIDCProtocolTest.php
  65. 23
    11
      tests/OpenIdProtocolTest.php
  66. 2
    3
      tests/OpenStackIDBaseTest.php
  67. 14
    3
      tests/ResourceServerApiTest.php
  68. 0
    1
      tests/StubServerConfigurationService.php
  69. 17
    52
      tests/TestCase.php
  70. 5
    2
      tests/TokenRepositoryTest.php
  71. 16
    15
      tests/TrustedSitesServiceTest.php
  72. 19
    0
      tests/Unit/ExampleTest.php
  73. 2
    7
      tests/UserGeneratorServiceTest.php
  74. 2
    4
      tests/UserServiceTest.php
  75. 2
    2
      tests/UserTest.php
  76. 2
    2
      tests/XRDSDocumentTest.php
  77. 15
    0
      webpack.mix.js

+ 2
- 1
.gitignore View File

@@ -32,4 +32,5 @@ public/assets/css/index.css
32 32
 /public/assets/pwstrength-bootstrap/
33 33
 /public/assets/sweetalert2/
34 34
 /public/assets/urijs
35
-/public/assets/uri.js
35
+/public/assets/uri.js
36
+_intellij_phpdebug_validator.php

+ 7
- 1
app/Http/Controllers/Api/ApiEndpointController.php View File

@@ -20,6 +20,7 @@ use OAuth2\Exceptions\InvalidApiEndpoint;
20 20
 use OAuth2\Exceptions\InvalidApiScope;
21 21
 use OAuth2\Repositories\IApiEndpointRepository;
22 22
 use OAuth2\Services\IApiEndpointService;
23
+use Utils\Exceptions\EntityNotFoundException;
23 24
 use Utils\Services\ILogService;
24 25
 
25 26
 /**
@@ -65,7 +66,12 @@ class ApiEndpointController extends AbstractRESTController implements ICRUDContr
65 66
             $data           = $api_endpoint->toArray();
66 67
             $data['scopes'] = $scopes->toArray();
67 68
             return $this->ok($data);
68
-        } catch (Exception $ex) {
69
+        }
70
+        catch (EntityNotFoundException $ex1) {
71
+            $this->log_service->warning($ex1);
72
+            return $this->error404($ex1);
73
+        }
74
+        catch (Exception $ex) {
69 75
             $this->log_service->error($ex);
70 76
             return $this->error500($ex);
71 77
         }

+ 1
- 1
app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php View File

@@ -57,7 +57,7 @@ class OAuth2UserApiController extends OAuth2ProtectedController
57 57
         IdTokenBuilder $id_token_builder
58 58
     )
59 59
     {
60
-        parent::__construct($resource_server_context,$log_service);
60
+        parent::__construct($resource_server_context, $log_service);
61 61
 
62 62
         $this->user_service      = $user_service;
63 63
         $this->client_repository = $client_repository;

+ 1
- 3
app/Http/Controllers/Controller.php View File

@@ -15,13 +15,11 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
15 15
 use Illuminate\Routing\Controller as BaseController;
16 16
 use Illuminate\Foundation\Validation\ValidatesRequests;
17 17
 use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
18
-use Illuminate\Foundation\Auth\Access\AuthorizesResources;
19
-
20 18
 /**
21 19
  * Class Controller
22 20
  * @package App\Http\Controllers
23 21
  */
24 22
 class Controller extends BaseController
25 23
 {
26
-    use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
24
+    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
27 25
 }

+ 1
- 1
app/Http/Controllers/OAuth2/OAuth2ProviderController.php View File

@@ -68,7 +68,7 @@ final class OAuth2ProviderController extends Controller
68 68
     {
69 69
         $this->oauth2_protocol    = $oauth2_protocol;
70 70
         $this->auth_service       = $auth_service;
71
-        $this->client_repository = $client_repository;
71
+        $this->client_repository  = $client_repository;
72 72
     }
73 73
 
74 74
     /**

+ 44
- 34
app/Http/Controllers/UserController.php View File

@@ -111,6 +111,11 @@ final class UserController extends OpenIdController
111 111
      */
112 112
     private $utils_configuration_service;
113 113
 
114
+    /**
115
+     * @var ISecurityContextService
116
+     */
117
+    private $security_context_service;
118
+
114 119
     /**
115 120
      * UserController constructor.
116 121
      * @param IMementoOpenIdSerializerService $openid_memento_service
@@ -160,51 +165,56 @@ final class UserController extends OpenIdController
160 165
         $this->token_service                = $token_service;
161 166
         $this->resource_server_service      = $resource_server_service;
162 167
         $this->utils_configuration_service  = $utils_configuration_service;
168
+        $this->security_context_service     = $security_context_service;
163 169
 
164
-        if ($this->openid_memento_service->exists())
165
-        {
166
-            //openid stuff
167
-            $this->login_strategy   = new OpenIdLoginStrategy
168
-            (
169
-                $openid_memento_service,
170
-                $user_action_service,
171
-                $auth_service
172
-            );
170
+        $this->middleware(function ($request, $next) {
171
+            if ($this->openid_memento_service->exists())
172
+            {
173
+                //openid stuff
174
+                $this->login_strategy   = new OpenIdLoginStrategy
175
+                (
176
+                    $this->openid_memento_service,
177
+                    $this->user_action_service,
178
+                    $this->auth_service
179
+                );
173 180
 
174
-            $this->consent_strategy = new OpenIdConsentStrategy
175
-            (
176
-                $openid_memento_service,
177
-                $auth_service,
178
-                $server_configuration_service,
179
-                $user_action_service
180
-            );
181
+                $this->consent_strategy = new OpenIdConsentStrategy
182
+                (
183
+                    $this->openid_memento_service,
184
+                    $this->auth_service,
185
+                    $this->server_configuration_service,
186
+                    $this->user_action_service
187
+                );
181 188
 
182
-        }
183
-        else if ($this->oauth2_memento_service->exists())
184
-        {
189
+            }
190
+            else if ($this->oauth2_memento_service->exists())
191
+            {
185 192
 
186 193
                 $this->login_strategy = new OAuth2LoginStrategy
187 194
                 (
188
-                    $auth_service,
189
-                    $oauth2_memento_service,
190
-                    $user_action_service,
191
-                    $security_context_service
195
+                    $this->auth_service,
196
+                    $this->oauth2_memento_service,
197
+                    $this->user_action_service,
198
+                    $this->security_context_service
192 199
                 );
193 200
 
194 201
                 $this->consent_strategy = new OAuth2ConsentStrategy
195 202
                 (
196
-                    $auth_service,
197
-                    $oauth2_memento_service,
198
-                    $scope_repository,
199
-                    $client_repository
203
+                    $this->auth_service,
204
+                    $this->oauth2_memento_service,
205
+                    $this->scope_repository,
206
+                    $this->client_repository
200 207
                 );
201
-        }
202
-        else
203
-        {
204
-            //default stuff
205
-            $this->login_strategy   = new DefaultLoginStrategy($user_action_service, $auth_service);
206
-            $this->consent_strategy = null;
207
-        }
208
+            }
209
+            else
210
+            {
211
+                //default stuff
212
+                $this->login_strategy   = new DefaultLoginStrategy($this->user_action_service, $this->auth_service);
213
+                $this->consent_strategy = null;
214
+            }
215
+
216
+            return $next($request);
217
+        });
208 218
     }
209 219
 
210 220
     public function getLogin()

+ 2
- 4
app/Http/Middleware/CORSMiddleware.php View File

@@ -1,5 +1,4 @@
1 1
 <?php namespace App\Http\Middleware;
2
-
3 2
 /**
4 3
  * Copyright 2015 OpenStack Foundation
5 4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +20,7 @@ use Symfony\Component\HttpFoundation\Response;
21 20
 use Illuminate\Support\Facades\Cache;
22 21
 use Carbon\Carbon;
23 22
 use Illuminate\Support\Facades\Config;
24
-use Illuminate\Support\Facades\Route;
25
-
23
+use libs\utils\RequestUtils;
26 24
 /**
27 25
  *
28 26
  * @package App\Http\Middleware\
@@ -141,7 +139,7 @@ final class CORSMiddleware
141 139
                     // correct route
142 140
                     $real_method = $request->headers->get('Access-Control-Request-Method');
143 141
 
144
-                    $route_path  = Route::getCurrentRoute()->getPath();
142
+                    $route_path  = RequestUtils::getCurrentRoutePath($request);
145 143
                     if (strpos($route_path, '/') != 0)
146 144
                         $route_path = '/' . $route_path;
147 145
 

+ 17
- 0
app/Http/Middleware/CheckForMaintenanceMode.php View File

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
6
+
7
+class CheckForMaintenanceMode extends Middleware
8
+{
9
+    /**
10
+     * The URIs that should be reachable while maintenance mode is enabled.
11
+     *
12
+     * @var array
13
+     */
14
+    protected $except = [
15
+        //
16
+    ];
17
+}

+ 2
- 2
app/Http/Middleware/CurrentUserCanEditOAuth2Client.php View File

@@ -58,10 +58,10 @@ final class CurrentUserCanEditOAuth2Client
58 58
     {
59 59
         try{
60 60
             $route                  = Route::getCurrentRoute();
61
-            $client_id              = $route->getParameter('id');
61
+            $client_id              = $route->parameter('id');
62 62
 
63 63
             if(is_null($client_id))
64
-                $client_id          = $route->getParameter('client_id');
64
+                $client_id          = $route->parameter('client_id');
65 65
 
66 66
             if(is_null($client_id))
67 67
                 $client_id          = Input::get('client_id',null);;

+ 2
- 2
app/Http/Middleware/CurrentUserCheckRouteParams.php View File

@@ -45,10 +45,10 @@ class CurrentUserCheckRouteParams
45 45
                 $used_id            = Input::get('id',null);
46 46
 
47 47
             if(is_null($used_id))
48
-                $used_id =  $route->getParameter('user_id');
48
+                $used_id =  $route->parameter('user_id');
49 49
 
50 50
             if(is_null($used_id))
51
-                $used_id =  $route->getParameter('id');
51
+                $used_id =  $route->parameter('id');
52 52
 
53 53
             $user                   = $authentication_service->getCurrentUser();
54 54
             if (is_null($used_id) || intval($used_id) !== intval($user->getId()))

+ 2
- 2
app/Http/Middleware/CurrentUserOwnsOAuth2Client.php View File

@@ -58,10 +58,10 @@ class CurrentUserOwnsOAuth2Client
58 58
     {
59 59
         try{
60 60
             $route                  = Route::getCurrentRoute();
61
-            $client_id              = $route->getParameter('id');
61
+            $client_id              = $route->parameter('id');
62 62
 
63 63
             if(is_null($client_id))
64
-                $client_id          = $route->getParameter('client_id');
64
+                $client_id          = $route->parameter('client_id');
65 65
 
66 66
             if(is_null($client_id))
67 67
                 $client_id          = Input::get('client_id',null);;

+ 25
- 7
app/Http/Middleware/EncryptCookies.php View File

@@ -1,14 +1,25 @@
1 1
 <?php namespace App\Http\Middleware;
2
-
2
+/**
3
+ * Copyright 2015 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Illuminate\Contracts\Encryption\DecryptException;
15
+use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
3 16
 use OAuth2\Services\IPrincipalService;
4 17
 use Symfony\Component\HttpFoundation\Request;
5
-use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
6
-use Illuminate\Contracts\Encryption\DecryptException;
7
-/***
18
+/**
8 19
  * Class EncryptCookies
9 20
  * @package App\Http\Middleware
10 21
  */
11
-class EncryptCookies extends BaseEncrypter
22
+class EncryptCookies extends Middleware
12 23
 {
13 24
     /**
14 25
      * The names of the cookies that should not be encrypted.
@@ -19,15 +30,21 @@ class EncryptCookies extends BaseEncrypter
19 30
         IPrincipalService::OP_BROWSER_STATE_COOKIE_NAME
20 31
     ];
21 32
 
33
+    /**
34
+     * Decrypt the cookies on the request.
35
+     *
36
+     * @param  \Symfony\Component\HttpFoundation\Request  $request
37
+     * @return \Symfony\Component\HttpFoundation\Request
38
+     */
22 39
     protected function decrypt(Request $request)
23 40
     {
24
-        foreach ($request->cookies as $key => $c) {
41
+        foreach ($request->cookies as $key => $cookie) {
25 42
             if ($this->isDisabled($key)) {
26 43
                 continue;
27 44
             }
28 45
 
29 46
             try {
30
-                $request->cookies->set($key, $this->decryptCookie($c));
47
+                $request->cookies->set($key, $this->decryptCookie($key, $cookie));
31 48
             } catch (DecryptException $e) {
32 49
                 $request->cookies->set($key, null);
33 50
             }
@@ -38,4 +55,5 @@ class EncryptCookies extends BaseEncrypter
38 55
 
39 56
         return $request;
40 57
     }
58
+
41 59
 }

+ 2
- 3
app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php View File

@@ -28,13 +28,12 @@ use OAuth2\Responses\OAuth2WWWAuthenticateErrorResponse;
28 28
 use OAuth2\Services\ITokenService;
29 29
 use OAuth2\IResourceServerContext;
30 30
 use OAuth2\Repositories\IApiEndpointRepository;
31
-use OAuth2\Services\IClientService;
32 31
 use URL\Normalizer;
33 32
 use Illuminate\Support\Facades\Route;
34 33
 use Exception;
35 34
 use Utils\Services\ICheckPointService;
36 35
 use Utils\Services\ILogService;
37
-
36
+use libs\utils\RequestUtils;
38 37
 /**
39 38
  * Class OAuth2BearerAccessTokenRequestValidator
40 39
  * this class implements the logic to Accessing to Protected Resources
@@ -117,7 +116,7 @@ final class OAuth2BearerAccessTokenRequestValidator
117 116
         $realm  = $request->getHost();
118 117
 
119 118
         try {
120
-            $route_path  = Route::getCurrentRoute()->getPath();
119
+            $route_path  = RequestUtils::getCurrentRoutePath($request);
121 120
             if (strpos($route_path, '/') != 0)
122 121
                 $route_path = '/' . $route_path;
123 122
 

+ 1
- 3
app/Http/Middleware/RedirectIfAuthenticated.php View File

@@ -11,10 +11,8 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
15 14
 use Closure;
16 15
 use Illuminate\Support\Facades\Auth;
17
-
18 16
 /**
19 17
  * Class RedirectIfAuthenticated
20 18
  * @package App\Http\Middleware
@@ -32,7 +30,7 @@ class RedirectIfAuthenticated
32 30
     public function handle($request, Closure $next, $guard = null)
33 31
     {
34 32
         if (Auth::guard($guard)->check()) {
35
-            return redirect('/');
33
+            return redirect('/home');
36 34
         }
37 35
 
38 36
         return $next($request);

+ 18
- 0
app/Http/Middleware/TrimStrings.php View File

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
6
+
7
+class TrimStrings extends Middleware
8
+{
9
+    /**
10
+     * The names of the attributes that should not be trimmed.
11
+     *
12
+     * @var array
13
+     */
14
+    protected $except = [
15
+        'password',
16
+        'password_confirmation',
17
+    ];
18
+}

+ 23
- 0
app/Http/Middleware/TrustProxies.php View File

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Http\Request;
6
+use Fideloper\Proxy\TrustProxies as Middleware;
7
+
8
+class TrustProxies extends Middleware
9
+{
10
+    /**
11
+     * The trusted proxies for this application.
12
+     *
13
+     * @var array
14
+     */
15
+    protected $proxies;
16
+
17
+    /**
18
+     * The headers that should be used to detect proxies.
19
+     *
20
+     * @var int
21
+     */
22
+    protected $headers = Request::HEADER_X_FORWARDED_ALL;
23
+}

+ 2
- 2
app/Http/Middleware/VerifyCsrfToken.php View File

@@ -2,9 +2,9 @@
2 2
 
3 3
 namespace App\Http\Middleware;
4 4
 
5
-use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
5
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
6 6
 
7
-class VerifyCsrfToken extends BaseVerifier
7
+class VerifyCsrfToken extends Middleware
8 8
 {
9 9
     /**
10 10
      * The URIs that should be excluded from CSRF verification.

+ 2
- 2
app/Models/OAuth2/ServerPrivateKey.php View File

@@ -16,7 +16,7 @@ use jwk\impl\RSAJWKFactory;
16 16
 use jwk\impl\RSAJWKPEMPrivateKeySpecification;
17 17
 use OAuth2\Models\IServerPrivateKey;
18 18
 use DateTime;
19
-use Crypt_RSA;
19
+use phpseclib\Crypt\RSA;
20 20
 use Illuminate\Support\Facades\Crypt;
21 21
 /**
22 22
  * Class ServerPrivateKey
@@ -122,7 +122,7 @@ final class ServerPrivateKey extends AsymmetricKey implements IServerPrivateKey
122 122
     public function getPublicKeyPEM()
123 123
     {
124 124
         $private_key_pem =  $this->pem_content;
125
-        $rsa             = new Crypt_RSA();
125
+        $rsa             = new RSA();
126 126
 
127 127
         if(!empty($this->password)){
128 128
             $rsa->setPassword($this->password);

+ 4
- 5
app/Providers/AppServiceProvider.php View File

@@ -31,9 +31,10 @@ class AppServiceProvider extends ServiceProvider
31 31
      */
32 32
     public function boot()
33 33
     {
34
-        $monolog = Log::getMonolog();
35 34
 
36
-        foreach($monolog->getHandlers() as $handler) {
35
+        $logger = Log::getLogger();
36
+
37
+        foreach($logger->getHandlers() as $handler) {
37 38
             $handler->setLevel(Config::get('log.level', 'error'));
38 39
         }
39 40
 
@@ -44,11 +45,9 @@ class AppServiceProvider extends ServiceProvider
44 45
         if (!empty($to) && !empty($from)) {
45 46
 
46 47
             $subject  = 'openstackid error';
47
-            $mono_log = Log::getMonolog();
48 48
             $handler  = new NativeMailerHandler($to, $subject, $from);
49
-
50 49
             $handler->setLevel(Config::get('log.email_level', 'error'));
51
-            $mono_log->pushHandler($handler);
50
+            $logger->pushHandler($handler);
52 51
         }
53 52
 
54 53
 

+ 2
- 3
app/Providers/AuthServiceProvider.php View File

@@ -34,10 +34,9 @@ class AuthServiceProvider extends ServiceProvider
34 34
      * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
35 35
      * @return void
36 36
      */
37
-    public function boot(GateContract $gate)
37
+    public function boot()
38 38
     {
39
-        $this->registerPolicies($gate);
40
-
39
+        $this->registerPolicies();
41 40
         //
42 41
     }
43 42
 }

+ 3
- 5
app/Providers/EventServiceProvider.php View File

@@ -36,10 +36,8 @@ class EventServiceProvider extends ServiceProvider
36 36
      * @param  \Illuminate\Contracts\Events\Dispatcher  $events
37 37
      * @return void
38 38
      */
39
-    public function boot(DispatcherContract $events)
39
+    public function boot()
40 40
     {
41
-        parent::boot($events);
42
-
43
-        //
44
-    }
41
+        parent::boot();
42
+   }
45 43
 }

+ 2
- 2
app/Providers/RouteServiceProvider.php View File

@@ -34,9 +34,9 @@ final class RouteServiceProvider extends ServiceProvider
34 34
      * @param  \Illuminate\Routing\Router  $router
35 35
      * @return void
36 36
      */
37
-    public function boot(Router $router)
37
+    public function boot()
38 38
     {
39
-        parent::boot($router);
39
+        parent::boot();
40 40
     }
41 41
 
42 42
     /**

+ 12
- 3
app/Services/OAuth2/ApiEndpointService.php View File

@@ -11,7 +11,6 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
15 14
 use OAuth2\Models\IApiEndpoint;
16 15
 use OAuth2\Repositories\IApiEndpointRepository;
17 16
 use OAuth2\Repositories\IApiScopeRepository;
@@ -21,12 +20,11 @@ use OAuth2\Exceptions\InvalidApiEndpoint;
21 20
 use OAuth2\Exceptions\InvalidApiScope;
22 21
 use Utils\Db\ITransactionService;
23 22
 use Utils\Exceptions\EntityNotFoundException;
24
-
25 23
 /**
26 24
  * Class ApiEndpointService
27 25
  * @package Services\OAuth2
28 26
  */
29
-class ApiEndpointService implements IApiEndpointService {
27
+final class ApiEndpointService implements IApiEndpointService {
30 28
 
31 29
     /**
32 30
      * @var ITransactionService
@@ -272,4 +270,15 @@ class ApiEndpointService implements IApiEndpointService {
272 270
             return true;
273 271
         });
274 272
     }
273
+
274
+    /**
275
+     * @param int $id
276
+     * @return mixed
277
+     */
278
+    public function get($id)
279
+    {
280
+        return $this->tx_service->transaction(function () use($id){
281
+           return $this->repository->get($id);
282
+        });
283
+    }
275 284
 }

+ 5
- 2
app/Services/OAuth2/HttpIClientJWKSetReader.php View File

@@ -18,7 +18,8 @@ use OAuth2\Services\IClientJWKSetReader;
18 18
 use GuzzleHttp\Client as HttpClient;
19 19
 use GuzzleHttp\Exception\RequestException as HttpRequestException;
20 20
 use Utils\Http\HttpContentType;
21
-use Log;
21
+use Illuminate\Support\Facades\Log;
22
+use Illuminate\Support\Facades\Config;
22 23
 /**
23 24
  * Class HttpIClientJWKSetReader
24 25
  * @package Services\OAuth2
@@ -28,7 +29,9 @@ final class HttpIClientJWKSetReader implements IClientJWKSetReader
28 29
 
29 30
     /**
30 31
      * @param IClient $client
31
-     * @return IJWKSet
32
+     * @return IJWKSet|null
33
+     * @throws \jwk\exceptions\InvalidJWKAlgorithm
34
+     * @throws \jwk\exceptions\JWKInvalidIdentifierException
32 35
      */
33 36
     public function read(IClient $client)
34 37
     {

+ 2
- 2
app/Services/OAuth2/PrincipalService.php View File

@@ -11,7 +11,7 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
14
+use phpseclib\Crypt\Random;
15 15
 use Illuminate\Support\Facades\Cookie;
16 16
 use Illuminate\Support\Facades\Session;
17 17
 use Illuminate\Support\Facades\Log;
@@ -78,7 +78,7 @@ final class PrincipalService implements IPrincipalService
78 78
         Log::debug(sprintf("PrincipalService::register user_id %s auth_time %s", $user_id, $auth_time));
79 79
         Session::put(self::UserIdParam, $user_id);
80 80
         Session::put(self::AuthTimeParam, $auth_time);
81
-        $opbs = bin2hex(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM));
81
+        $opbs = bin2hex(Random::string(16));
82 82
         Cookie::queue(IPrincipalService::OP_BROWSER_STATE_COOKIE_NAME, $opbs, $minutes = config("session.op_browser_state_lifetime"), $path = '/', $domain = null, $secure = false, $httpOnly = false);
83 83
         Log::debug(sprintf("PrincipalService::register opbs %s", $opbs));
84 84
         Session::put(self::OPBrowserState, $opbs);

+ 3
- 3
app/Services/OAuth2/ServerPrivateKeyService.php View File

@@ -18,7 +18,7 @@ use OAuth2\Repositories\IServerPrivateKeyRepository;
18 18
 use Utils\Db\ITransactionService;
19 19
 use Models\OAuth2\ServerPrivateKey;
20 20
 use DateTime;
21
-use Crypt_RSA;
21
+use phpseclib\Crypt\RSA;
22 22
 use Services\Exceptions\ValidationException;
23 23
 
24 24
 /**
@@ -29,7 +29,7 @@ final class ServerPrivateKeyService extends AsymmetricKeyService implements ISer
29 29
 {
30 30
 
31 31
     /**
32
-     * @var Crypt_RSA
32
+     * @var RSA
33 33
      */
34 34
     private $rsa;
35 35
 
@@ -45,7 +45,7 @@ final class ServerPrivateKeyService extends AsymmetricKeyService implements ISer
45 45
     )
46 46
     {
47 47
         parent::__construct($repository, $tx_service);
48
-        $this->rsa = new Crypt_RSA();
48
+        $this->rsa = new RSA();
49 49
     }
50 50
 
51 51
     /**

+ 0
- 1
app/Services/OpenId/OpenIdMementoSessionSerializerService.php View File

@@ -14,7 +14,6 @@
14 14
 use OpenId\Requests\OpenIdMessageMemento;
15 15
 use OpenId\Services\IMementoOpenIdSerializerService;
16 16
 use Illuminate\Support\Facades\Session;
17
-
18 17
 /**
19 18
  * Class OpenIdMementoSessionSerializerService
20 19
  * @package Services\OpenId

+ 1
- 1
app/Services/OpenId/TrustedSitesService.php View File

@@ -69,7 +69,7 @@ class TrustedSitesService implements ITrustedSitesService
69 69
 			$site->user_id = $user->getId();
70 70
 			$site->data    = json_encode($data);
71 71
 
72
-			return $this->repository->add($site)?$site:false;
72
+			return $this->repository->add($site) ? $site : false;
73 73
 
74 74
 		} catch (Exception $ex) {
75 75
 			$this->log_service->error($ex);

+ 2
- 4
app/Services/Utils/UtilsProvider.php View File

@@ -11,13 +11,11 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
15 14
 use Utils\Services\UtilsServiceCatalog;
16 15
 use Illuminate\Support\ServiceProvider;
17 16
 use Illuminate\Foundation\AliasLoader;
18 17
 use Illuminate\Support\Facades\App;
19 18
 use Illuminate\Support\Facades\Log;
20
-
21 19
 /**
22 20
  * Class UtilsProvider
23 21
  * @package Services\Utils
@@ -41,7 +39,7 @@ final class UtilsProvider extends ServiceProvider {
41 39
         App::singleton(UtilsServiceCatalog::BannedIpService, 'Services\\Utils\\BannedIPService');
42 40
 
43 41
         // setting facade
44
-        $this->app['serverconfigurationservice'] = App::share(function ($app) {
42
+        App::singleton('serverconfigurationservice', function ($app) {
45 43
             return new ServerConfigurationService
46 44
             (
47 45
                 App::make(UtilsServiceCatalog::CacheService),
@@ -50,7 +48,7 @@ final class UtilsProvider extends ServiceProvider {
50 48
         });
51 49
 
52 50
         // setting facade
53
-        $this->app['externalurlservice'] = App::share(function ($app) {
51
+        App::singleton('externalurlservice', function ($app) {
54 52
             return new ExternalUrlService();
55 53
         });
56 54
 

+ 10
- 10
app/Validators/CustomValidator.php View File

@@ -13,13 +13,13 @@
13 13
  **/
14 14
 use Illuminate\Validation\Validator;
15 15
 use Models\OAuth2\Client;
16
-use Symfony\Component\Translation\TranslatorInterface;
16
+use Illuminate\Contracts\Translation\Translator;
17 17
 use jwk\JSONWebKeyPublicKeyUseValues;
18 18
 use jwk\JSONWebKeyTypes;
19 19
 use OAuth2\OAuth2Protocol;
20 20
 use OAuth2\Models\IClient;
21 21
 use Utils\Services\IAuthService;
22
-use Crypt_RSA;
22
+use phpseclib\Crypt\RSA;
23 23
 
24 24
 /**
25 25
  * Class CustomValidator
@@ -37,7 +37,7 @@ class CustomValidator extends Validator
37 37
         'RequiredWithoutField'
38 38
     );
39 39
 
40
-    public function __construct(TranslatorInterface $translator, $data, $rules, $messages = array())
40
+    public function __construct(Translator $translator, $data, $rules, $messages = array())
41 41
     {
42 42
         parent::__construct($translator, $data, $rules, $messages);
43 43
         $this->isImplicit('fail');
@@ -221,7 +221,7 @@ class CustomValidator extends Validator
221 221
         $PKCS8 = $res1 !== false && $res3 !== false;
222 222
         $PKCS1 = $res2 !== false && $res4 !== false;
223 223
 
224
-        $rsa    = new Crypt_RSA;
224
+        $rsa    = new RSA;
225 225
         $parsed = $rsa->loadKey($value);
226 226
 
227 227
         return ($PKCS8 || $PKCS1) && $parsed;
@@ -229,7 +229,7 @@ class CustomValidator extends Validator
229 229
 
230 230
     public function validatePublicKeyPemLength($attribute, $value)
231 231
     {
232
-        $rsa    = new Crypt_RSA();
232
+        $rsa    = new RSA();
233 233
         $parsed = $rsa->loadKey($value);
234 234
 
235 235
         return $parsed && $rsa->getSize() > 1024;
@@ -247,7 +247,7 @@ class CustomValidator extends Validator
247 247
 
248 248
         $encrypted      = strpos($value,'ENCRYPTED') !== false ;
249 249
         $password_param = $parameters[0];
250
-        $rsa            = new Crypt_RSA;
250
+        $rsa            = new RSA;
251 251
         if(isset($this->data[$password_param]) && $encrypted){
252 252
             $rsa->setPassword($this->data[$password_param]);
253 253
         }
@@ -262,7 +262,7 @@ class CustomValidator extends Validator
262 262
 
263 263
         $encrypted      = strpos($value,'ENCRYPTED') !== false ;
264 264
         $password_param = $parameters[0];
265
-        $rsa            = new Crypt_RSA;
265
+        $rsa            = new RSA;
266 266
         if(isset($this->data[$password_param]) && $encrypted){
267 267
             $rsa->setPassword($this->data[$password_param]);
268 268
         }
@@ -286,7 +286,7 @@ class CustomValidator extends Validator
286 286
        $pem_param = $parameters[0];
287 287
        if(!isset($this->data[$pem_param])) return true;
288 288
        $pem_content = $this->data[$pem_param];
289
-       $rsa    = new Crypt_RSA;
289
+       $rsa    = new RSA;
290 290
        $rsa->setPassword($value);
291 291
        $parsed = $rsa->loadKey($pem_content);
292 292
        return $parsed;
@@ -301,7 +301,7 @@ class CustomValidator extends Validator
301 301
         $urls = explode(',', $value);
302 302
         $res = true;
303 303
         foreach ($urls as $url) {
304
-            $res = $app_type === IClient::ApplicationType_Native ? $this->validateCustomUrl($attribute, $url, $parameters): $this->validateSslurl($attribute, $url, $parameters);
304
+            $res = $app_type === IClient::ApplicationType_Native ? $this->validateCustomUrl($attribute, $url, $parameters): $this->validateSslurl($attribute, $url);
305 305
             if (!$res) {
306 306
                 break;
307 307
             }
@@ -324,7 +324,7 @@ class CustomValidator extends Validator
324 324
         $urls = explode(',', $value);
325 325
         $res = true;
326 326
         foreach ($urls as $url) {
327
-            $res = $this->validateSslurl($attribute, $url, $parameters);
327
+            $res = $this->validateSslurl($attribute, $url);
328 328
             if (!$res) {
329 329
                 break;
330 330
             }

+ 3
- 3
app/libs/Auth/AuthService.php View File

@@ -132,7 +132,7 @@ final class AuthService implements IAuthService
132 132
     }
133 133
 
134 134
     /**
135
-     * @return AuthorizationResponse_*
135
+     * @return string
136 136
      */
137 137
     public function getUserAuthorizationResponse()
138 138
     {
@@ -158,7 +158,7 @@ final class AuthService implements IAuthService
158 158
 
159 159
     public function setUserAuthorizationResponse($auth_response)
160 160
     {
161
-        Session::set("openid.authorization.response", $auth_response);
161
+        Session::put("openid.authorization.response", $auth_response);
162 162
         Session::save();
163 163
     }
164 164
 
@@ -216,7 +216,7 @@ final class AuthService implements IAuthService
216 216
 
217 217
     public function setUserAuthenticationResponse($auth_response)
218 218
     {
219
-        Session::set("openstackid.authentication.response", $auth_response);
219
+        Session::put("openstackid.authentication.response", $auth_response);
220 220
         Session::save();
221 221
     }
222 222
 

+ 2
- 3
app/libs/OAuth2/GrantTypes/InteractiveGrantType.php View File

@@ -57,7 +57,7 @@ use utils\exceptions\InvalidCompactSerializationException;
57 57
 use utils\factories\BasicJWTFactory;
58 58
 use Utils\Services\IAuthService;
59 59
 use Utils\Services\ILogService;
60
-
60
+use phpseclib\Crypt\Random;
61 61
 /**
62 62
  * Class InteractiveGrantType
63 63
  * @package OAuth2\GrantTypes
@@ -327,8 +327,7 @@ abstract class InteractiveGrantType extends AbstractGrantType
327 327
             $session_id
328 328
         ));
329 329
 
330
-        // warning: mcrypt_create_iv deprecated on php 7.x
331
-        $salt    = bin2hex(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM));
330
+        $salt    = bin2hex(Random::string(16));
332 331
         $message = "{$client_id}{$origin}{$session_id}{$salt}";
333 332
         $this->log_service->debug_msg(sprintf(
334 333
             "InteractiveGrantType::getSessionState message %s",

+ 6
- 0
app/libs/OAuth2/Services/IApiEndpointService.php View File

@@ -69,6 +69,12 @@ interface IApiEndpointService {
69 69
      */
70 70
     public function delete($id);
71 71
 
72
+    /**
73
+     * @param int $id
74
+     * @return mixed
75
+     */
76
+    public function get($id);
77
+
72 78
     /**
73 79
      * @param int $id
74 80
      * @param array $params

+ 45
- 0
app/libs/Utils/RequestUtils.php View File

@@ -0,0 +1,45 @@
1
+<?php namespace libs\utils;
2
+/**
3
+ * Copyright 2015 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Illuminate\Support\Facades\Route;
15
+use Illuminate\Support\Facades\Log;
16
+/**
17
+ * Class RequestUtils
18
+ * @package libs\utils
19
+ */
20
+final class RequestUtils {
21
+
22
+    /**
23
+     * @param \Illuminate\Http\Request $request
24
+     * @return bool|string
25
+     */
26
+    public static function getCurrentRoutePath($request)
27
+    {
28
+        try
29
+        {
30
+            $route = Route::getRoutes()->match($request);
31
+            if(is_null($route)) return false;
32
+            $route_path  = $route->uri();
33
+            if (strpos($route_path, '/') != 0)
34
+                $route_path = '/' . $route_path;
35
+
36
+            return $route_path;
37
+        }
38
+        catch (\Exception $ex)
39
+        {
40
+            Log::error($ex);
41
+        }
42
+        return false;
43
+    }
44
+
45
+}

+ 4
- 2
artisan View File

@@ -1,6 +1,8 @@
1 1
 #!/usr/bin/env php
2 2
 <?php
3 3
 
4
+define('LARAVEL_START', microtime(true));
5
+
4 6
 /*
5 7
 |--------------------------------------------------------------------------
6 8
 | Register The Auto Loader
@@ -13,7 +15,7 @@
13 15
 |
14 16
 */
15 17
 
16
-require __DIR__.'/bootstrap/autoload.php';
18
+require __DIR__.'/vendor/autoload.php';
17 19
 
18 20
 $app = require_once __DIR__.'/bootstrap/app.php';
19 21
 
@@ -40,7 +42,7 @@ $status = $kernel->handle(
40 42
 | Shutdown The Application
41 43
 |--------------------------------------------------------------------------
42 44
 |
43
-| Once Artisan has finished running. We will fire off the shutdown events
45
+| Once Artisan has finished running, we will fire off the shutdown events
44 46
 | so that any final work may be done by the application before we shut
45 47
 | down the process. This is the last thing to happen to the request.
46 48
 |

+ 12
- 19
bindep.txt View File

@@ -1,28 +1,21 @@
1
-mcrypt
1
+php7.2 [platform:dpkg]
2 2
 
3
-php [platform:ubuntu-xenial]
4
-php5 [platform:dpkg !platform:ubuntu-xenial]
3
+php7.2-cli [platform:dpkg]
5 4
 
6
-php-cli [platform:rpm platform:ubuntu-xenial]
7
-php5-cli [platform:dpkg !platform:ubuntu-xenial]
5
+php7.2-common [platform:dpkg]
8 6
 
9
-php-common  [platform:ubuntu-xenial]
10
-php5-common [platform:dpkg !platform:ubuntu-xenial]
7
+php7.2-curl [platform:dpkg]
11 8
 
12
-php-curl [platform:rpm platform:ubuntu-xenial]
13
-php5-curl [platform:dpkg !platform:ubuntu-xenial]
9
+php7.2-gd [platform:dpkg]
14 10
 
15
-php-gd [platform:rpm platform:ubuntu-xenial]
16
-php5-gd [platform:dpkg !platform:ubuntu-xenial]
11
+php7.2-json [platform:dpkg]
17 12
 
18
-php-json [platform:rpm platform:ubuntu-xenial]
19
-php5-json [platform:dpkg !platform:ubuntu-xenial]
13
+php7.2-mysqlnd [platform:dpkg]
20 14
 
21
-php-mysql [platform:rpm platform:ubuntu-xenial]
22
-php5-mysql [platform:dpkg !platform:ubuntu-xenial]
15
+php7.2-xml [platform:dpkg]
23 16
 
24
-php-gmp [platform:rpm platform:ubuntu-xenial]
25
-php5-gmp [platform:dpkg !platform:ubuntu-xenial]
17
+php7.2-mbstring [platform:dpkg]
26 18
 
27
-php-mcrypt [platform:ubuntu-xenial]
28
-php5-mcrypt [platform:dpkg !platform:ubuntu-xenial]
19
+php7.2-gmp [platform:dpkg]
20
+
21
+php7.2-ssh2 [platform:dpkg]

+ 89
- 66
composer.json View File

@@ -1,69 +1,92 @@
1 1
 {
2
-    "name": "laravel/laravel",
3
-    "description": "The Laravel Framework.",
4
-    "keywords": ["framework", "laravel"],
5
-    "license": "MIT",
6
-    "type": "project",
7
-    "require": {
8
-        "php": ">=5.5.9",
9
-        "laravel/framework": "5.2.*",
10
-        "zendframework/zend-crypt": "2.6.*",
11
-        "zendframework/zend-math": "2.7.*",
12
-        "ircmaxell/random-lib": "1.1.*",
13
-        "greggilbert/recaptcha": "2.1.*",
14
-        "guzzlehttp/guzzle": "5.3.0",
15
-        "smarcet/jose4php": "1.0.15",
16
-        "glenscott/url-normalizer" : "1.4.*",
17
-        "jenssegers/agent": "2.3.*",
18
-        "predis/predis": "1.0.1",
19
-        "laravelcollective/html": "5.2.4"
20
-    },
21
-    "require-dev": {
22
-        "fzaninotto/faker": "~1.4",
23
-        "phpunit/phpunit": "~4.0",
24
-        "symfony/css-selector": "2.8.*|3.0.*",
25
-        "symfony/dom-crawler": "2.8.*|3.0.*",
26
-        "doctrine/dbal": "*",
27
-        "mockery/mockery": "*",
28
-        "way/laravel-test-helpers": "dev-master"
29
-    },
30
-    "autoload": {
31
-        "classmap": [
32
-            "database",
33
-            "app",
34
-            "tests"
35
-        ],
36
-        "psr-4": {
37
-            "App\\"    : "app/",
38
-            "Auth\\"   : "app/libs/Auth/",
39
-            "OAuth2\\" : "app/libs/OAuth2/",
40
-            "OpenId\\" : "app/libs/OpenId/",
41
-            "Utils\\"  : "app/libs/Utils/",
42
-            "Models\\" : "app/Models/"
43
-        }
44
-    },
45
-    "autoload-dev": {
46
-        "classmap": [
47
-            "tests/TestCase.php"
48
-        ]
49
-    },
50
-    "scripts": {
51
-        "post-root-package-install": [
52
-            "php -r \"copy('.env.example', '.env');\""
53
-        ],
54
-        "post-create-project-cmd": [
55
-            "php artisan key:generate"
56
-        ],
57
-        "post-install-cmd": [
58
-            "Illuminate\\Foundation\\ComposerScripts::postInstall",
59
-            "php artisan optimize"
60
-        ],
61
-        "post-update-cmd": [
62
-            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
63
-            "php artisan optimize"
64
-        ]
65
-    },
66
-    "config": {
67
-        "preferred-install": "dist"
2
+  "name": "openstack/openstackid",
3
+  "description": "OpenStackID IDP",
4
+  "keywords": [
5
+    "idp",
6
+    "openstack",
7
+    "oauth2",
8
+    "openid2.0",
9
+    "jwt",
10
+    "oidc"
11
+  ],
12
+  "license": "MIT",
13
+  "type": "project",
14
+  "require": {
15
+    "php": "^7.1.3",
16
+    "fideloper/proxy": "^4.0",
17
+    "laravel/framework": "5.6.*",
18
+    "laravel/tinker": "^1.0",
19
+    "zendframework/zend-crypt": "3.3.0",
20
+    "zendframework/zend-math": "3.1.1",
21
+    "ircmaxell/random-lib": "1.1.*",
22
+    "greggilbert/recaptcha": "2.1.*",
23
+    "guzzlehttp/guzzle": "6.3.3",
24
+    "smarcet/jose4php": "dev-feature/php7.2-migration",
25
+    "glenscott/url-normalizer": "1.4.*",
26
+    "jenssegers/agent": "2.3.*",
27
+    "laravelcollective/html": "5.6.*",
28
+    "phpseclib/phpseclib": "2.0.11",
29
+    "predis/predis": "1.0.*",
30
+    "ext-json":"*",
31
+    "ext-pdo":"*"
32
+  },
33
+  "require-dev": {
34
+    "filp/whoops": "^2.0",
35
+    "fzaninotto/faker": "^1.4",
36
+    "mockery/mockery": "^1.0",
37
+    "nunomaduro/collision": "^2.0",
38
+    "phpunit/phpunit": "^7.0",
39
+    "laravel/browser-kit-testing": "4.0.2"
40
+  },
41
+  "suggest":{
42
+    "lib-openssl": "Required to use AES algorithms (except AES GCM)",
43
+    "ext-json":"Required to use json algorithms"
44
+  },
45
+  "autoload": {
46
+    "classmap": [
47
+      "database/seeds",
48
+      "database/factories",
49
+      "database",
50
+      "app",
51
+      "tests"
52
+    ],
53
+    "psr-4": {
54
+      "App\\": "app/",
55
+      "Auth\\": "app/libs/Auth/",
56
+      "OAuth2\\": "app/libs/OAuth2/",
57
+      "OpenId\\": "app/libs/OpenId/",
58
+      "Utils\\": "app/libs/Utils/",
59
+      "Models\\": "app/Models/"
68 60
     }
61
+  },
62
+  "autoload-dev": {
63
+    "psr-4": {
64
+      "Tests\\": "tests/"
65
+    }
66
+  },
67
+  "extra": {
68
+    "laravel": {
69
+      "dont-discover": [
70
+      ]
71
+    }
72
+  },
73
+  "scripts": {
74
+    "post-root-package-install": [
75
+      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
76
+    ],
77
+    "post-create-project-cmd": [
78
+      "@php artisan key:generate"
79
+    ],
80
+    "post-autoload-dump": [
81
+      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
82
+      "@php artisan package:discover"
83
+    ]
84
+  },
85
+  "config": {
86
+    "preferred-install": "dist",
87
+    "sort-packages": true,
88
+    "optimize-autoloader": true
89
+  },
90
+  "minimum-stability": "dev",
91
+  "prefer-stable": true
69 92
 }

+ 0
- 15
config/app.php View File

@@ -95,21 +95,6 @@ return [
95 95
 
96 96
     'cipher' => 'AES-256-CBC',
97 97
 
98
-    /*
99
-    |--------------------------------------------------------------------------
100
-    | Logging Configuration
101
-    |--------------------------------------------------------------------------
102
-    |
103
-    | Here you may configure the log settings for your application. Out of
104
-    | the box, Laravel uses the Monolog PHP logging library. This gives
105
-    | you a variety of powerful log handlers / formatters to utilize.
106
-    |
107
-    | Available Settings: "single", "daily", "syslog", "errorlog"
108
-    |
109
-    */
110
-
111
-    'log' => env('APP_LOG', 'single'),
112
-
113 98
     /*
114 99
     |--------------------------------------------------------------------------
115 100
     | Autoloaded Service Providers

+ 52
- 0
config/hashing.php View File

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Default Hash Driver
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | This option controls the default hash driver that will be used to hash
11
+    | passwords for your application. By default, the bcrypt algorithm is
12
+    | used; however, you remain free to modify this option if you wish.
13
+    |
14
+    | Supported: "bcrypt", "argon"
15
+    |
16
+    */
17
+
18
+    'driver' => 'bcrypt',
19
+
20
+    /*
21
+    |--------------------------------------------------------------------------
22
+    | Bcrypt Options
23
+    |--------------------------------------------------------------------------
24
+    |
25
+    | Here you may specify the configuration options that should be used when
26
+    | passwords are hashed using the Bcrypt algorithm. This will allow you
27
+    | to control the amount of time it takes to hash the given password.
28
+    |
29
+    */
30
+
31
+    'bcrypt' => [
32
+        'rounds' => env('BCRYPT_ROUNDS', 10),
33
+    ],
34
+
35
+    /*
36
+    |--------------------------------------------------------------------------
37
+    | Argon Options
38
+    |--------------------------------------------------------------------------
39
+    |
40
+    | Here you may specify the configuration options that should be used when
41
+    | passwords are hashed using the Argon algorithm. These will allow you
42
+    | to control the amount of time it takes to hash the given password.
43
+    |
44
+    */
45
+
46
+    'argon' => [
47
+        'memory' => 1024,
48
+        'threads' => 2,
49
+        'time' => 2,
50
+    ],
51
+
52
+];

+ 81
- 0
config/logging.php View File

@@ -0,0 +1,81 @@
1
+<?php
2
+
3
+use Monolog\Handler\StreamHandler;
4
+
5
+return [
6
+
7
+    /*
8
+    |--------------------------------------------------------------------------
9
+    | Default Log Channel
10
+    |--------------------------------------------------------------------------
11
+    |
12
+    | This option defines the default log channel that gets used when writing
13
+    | messages to the logs. The name specified in this option should match
14
+    | one of the channels defined in the "channels" configuration array.
15
+    |
16
+    */
17
+
18
+    'default' => env('LOG_CHANNEL', 'stack'),
19
+
20
+    /*
21
+    |--------------------------------------------------------------------------
22
+    | Log Channels
23
+    |--------------------------------------------------------------------------
24
+    |
25
+    | Here you may configure the log channels for your application. Out of
26
+    | the box, Laravel uses the Monolog PHP logging library. This gives
27
+    | you a variety of powerful log handlers / formatters to utilize.
28
+    |
29
+    | Available Drivers: "single", "daily", "slack", "syslog",
30
+    |                    "errorlog", "monolog",
31
+    |                    "custom", "stack"
32
+    |
33
+    */
34
+
35
+    'channels' => [
36
+        'stack' => [
37
+            'driver' => 'stack',
38
+            'channels' => ['daily'],
39
+        ],
40
+
41
+        'single' => [
42
+            'driver' => 'single',
43
+            'path' => storage_path('logs/laravel.log'),
44
+            'level' => 'debug',
45
+        ],
46
+
47
+        'daily' => [
48
+            'driver' => 'daily',
49
+            'path' => storage_path('logs/laravel.log'),
50
+            'level' => 'debug',
51
+            'days' => 7,
52
+        ],
53
+
54
+        'slack' => [
55
+            'driver' => 'slack',
56
+            'url' => env('LOG_SLACK_WEBHOOK_URL'),
57
+            'username' => 'Laravel Log',
58
+            'emoji' => ':boom:',
59
+            'level' => 'critical',
60
+        ],
61
+
62
+        'stderr' => [
63
+            'driver' => 'monolog',
64
+            'handler' => StreamHandler::class,
65
+            'with' => [
66
+                'stream' => 'php://stderr',
67
+            ],
68
+        ],
69
+
70
+        'syslog' => [
71
+            'driver' => 'syslog',
72
+            'level' => 'debug',
73
+        ],
74
+
75
+        'errorlog' => [
76
+            'driver' => 'errorlog',
77
+            'level' => 'debug',
78
+        ],
79
+    ],
80
+
81
+];

+ 17
- 0
config/session.php View File

@@ -162,9 +162,26 @@ return [
162 162
     */
163 163
 
164 164
     'http_only' => env('SESSION_COOKIE_HTTP_ONLY', true),
165
+
166
+    /*
167
+   |--------------------------------------------------------------------------
168
+   | Same-Site Cookies
169
+   |--------------------------------------------------------------------------
170
+   |
171
+   | This option determines how your cookies behave when cross-site requests
172
+   | take place, and can be used to mitigate CSRF attacks. By default, we
173
+   | do not enable this as other CSRF protection services are in place.
174
+   |
175
+   | Supported: "lax", "strict"
176
+   |
177
+   */
178
+
179
+    'same_site' => null,
180
+
165 181
     /*
166 182
      * http://openid.net/specs/openid-connect-session-1_0.html#OPiframe
167 183
      * OP Browser state lifetime
168 184
      */
169 185
     'op_browser_state_lifetime' => env('SESSION_OP_BROWSER_STATE_LIFETIME', 120)
186
+
170 187
 ];

+ 23
- 0
database/factories/UserFactory.php View File

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+use Faker\Generator as Faker;
4
+
5
+/*
6
+|--------------------------------------------------------------------------
7
+| Model Factories
8
+|--------------------------------------------------------------------------
9
+|
10
+| This directory should contain each of the model factory definitions for
11
+| your application. Factories provide a convenient way to generate new
12
+| model instances for testing / seeding your application's database.
13
+|
14
+*/
15
+
16
+$factory->define(App\User::class, function (Faker $faker) {
17
+    return [
18
+        'name' => $faker->name,
19
+        'email' => $faker->unique()->safeEmail,
20
+        'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
21
+        'remember_token' => str_random(10),
22
+    ];
23
+});

+ 21
- 12
package-lock.json View File

@@ -3841,11 +3841,13 @@
3841 3841
         },
3842 3842
         "balanced-match": {
3843 3843
           "version": "1.0.0",
3844
-          "bundled": true
3844
+          "bundled": true,
3845
+          "optional": true
3845 3846
         },
3846 3847
         "brace-expansion": {
3847 3848
           "version": "1.1.11",
3848 3849
           "bundled": true,
3850
+          "optional": true,
3849 3851
           "requires": {
3850 3852
             "balanced-match": "^1.0.0",
3851 3853
             "concat-map": "0.0.1"
@@ -3858,15 +3860,18 @@
3858 3860
         },
3859 3861
         "code-point-at": {
3860 3862
           "version": "1.1.0",
3861
-          "bundled": true
3863
+          "bundled": true,
3864
+          "optional": true
3862 3865
         },
3863 3866
         "concat-map": {
3864 3867
           "version": "0.0.1",
3865
-          "bundled": true
3868
+          "bundled": true,
3869
+          "optional": true
3866 3870
         },
3867 3871
         "console-control-strings": {
3868 3872
           "version": "1.1.0",
3869
-          "bundled": true
3873
+          "bundled": true,
3874
+          "optional": true
3870 3875
         },
3871 3876
         "core-util-is": {
3872 3877
           "version": "1.0.2",
@@ -3969,7 +3974,8 @@
3969 3974
         },
3970 3975
         "inherits": {
3971 3976
           "version": "2.0.3",
3972
-          "bundled": true
3977
+          "bundled": true,
3978
+          "optional": true
3973 3979
         },
3974 3980
         "ini": {
3975 3981
           "version": "1.3.5",
@@ -3979,6 +3985,7 @@
3979 3985
         "is-fullwidth-code-point": {
3980 3986
           "version": "1.0.0",
3981 3987
           "bundled": true,
3988
+          "optional": true,
3982 3989
           "requires": {
3983 3990
             "number-is-nan": "^1.0.0"
3984 3991
           }
@@ -3991,17 +3998,20 @@
3991 3998
         "minimatch": {
3992 3999
           "version": "3.0.4",
3993 4000
           "bundled": true,
4001
+          "optional": true,
3994 4002
           "requires": {
3995 4003
             "brace-expansion": "^1.1.7"
3996 4004
           }
3997 4005
         },
3998 4006
         "minimist": {
3999 4007
           "version": "0.0.8",
4000
-          "bundled": true
4008
+          "bundled": true,
4009
+          "optional": true
4001 4010
         },
4002 4011
         "minipass": {
4003 4012
           "version": "2.2.4",
4004 4013
           "bundled": true,
4014
+          "optional": true,
4005 4015
           "requires": {
4006 4016
             "safe-buffer": "^5.1.1",
4007 4017
             "yallist": "^3.0.0"
@@ -4018,6 +4028,7 @@
4018 4028
         "mkdirp": {
4019 4029
           "version": "0.5.1",
4020 4030
           "bundled": true,
4031
+          "optional": true,
4021 4032
           "requires": {
4022 4033
             "minimist": "0.0.8"
4023 4034
           }
@@ -4090,7 +4101,8 @@
4090 4101
         },
4091 4102
         "number-is-nan": {
4092 4103
           "version": "1.0.1",
4093
-          "bundled": true
4104
+          "bundled": true,
4105
+          "optional": true
4094 4106
         },
4095 4107
         "object-assign": {
4096 4108
           "version": "4.1.1",
@@ -4100,6 +4112,7 @@
4100 4112
         "once": {
4101 4113
           "version": "1.4.0",
4102 4114
           "bundled": true,
4115
+          "optional": true,
4103 4116
           "requires": {
4104 4117
             "wrappy": "1"
4105 4118
           }
@@ -4205,6 +4218,7 @@
4205 4218
         "string-width": {
4206 4219
           "version": "1.0.2",
4207 4220
           "bundled": true,
4221
+          "optional": true,
4208 4222
           "requires": {
4209 4223
             "code-point-at": "^1.0.0",
4210 4224
             "is-fullwidth-code-point": "^1.0.0",
@@ -11087,11 +11101,6 @@
11087 11101
         "punycode": "^2.1.0"
11088 11102
       }
11089 11103
     },
11090
-    "uri.js": {
11091
-      "version": "0.1.3",
11092
-      "resolved": "https://registry.npmjs.org/uri.js/-/uri.js-0.1.3.tgz",
11093
-      "integrity": "sha1-uT7umQWzyBucOLu83/9e9tDI3l8="
11094
-    },
11095 11104
     "urijs": {
11096 11105
       "version": "1.19.1",
11097 11106
       "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.1.tgz",

+ 1
- 1
phpunit.xml View File

@@ -8,7 +8,7 @@
8 8
          convertWarningsToExceptions="true"
9 9
          processIsolation="false"
10 10
          stopOnFailure="false"
11
-         syntaxCheck="false">
11
+>
12 12
     <testsuites>
13 13
         <testsuite name="Application Test Suite">
14 14
             <directory>./tests/</directory>

+ 1
- 1
public/assets/js/oauth2/profile/admin/server-private-keys.js View File

@@ -30,7 +30,7 @@
30 30
             todayBtn: "linked",
31 31
             clearBtn: true,
32 32
             todayHighlight: true,
33
-            orientation: "top right",
33
+            orientation: "bottom right",
34 34
             autoclose: true
35 35
         });
36 36
 

+ 1
- 1
public/assets/js/oauth2/profile/edit-client-public-keys.js View File

@@ -10,7 +10,7 @@
10 10
             todayBtn: "linked",
11 11
             clearBtn: true,
12 12
             todayHighlight: true,
13
-            orientation: "top right",
13
+            orientation: "bottom right",
14 14
             autoclose: true
15 15
         });
16 16
 

+ 1
- 1
server.php View File

@@ -4,7 +4,7 @@
4 4
  * Laravel - A PHP Framework For Web Artisans
5 5
  *
6 6
  * @package  Laravel
7
- * @author   Taylor Otwell <taylorotwell@gmail.com>
7
+ * @author   Taylor Otwell <taylor@laravel.com>
8 8
  */
9 9
 
10 10
 $uri = urldecode(

+ 16
- 3
tests/ApiEndpointTest.php View File

@@ -1,13 +1,24 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use Models\OAuth2\ApiEndpoint;
4 15
 use Models\OAuth2\Api;
5 16
 use Models\OAuth2\ApiScope;
6
-
17
+use Tests\BrowserKitTestCase;
7 18
 /**
8 19
  * Class ApiEndpointTest
9 20
  */
10
-class ApiEndpointTest extends TestCase {
21
+final class ApiEndpointTest extends BrowserKitTestCase {
11 22
 
12 23
     private $current_realm;
13 24
 
@@ -190,6 +201,8 @@ class ApiEndpointTest extends TestCase {
190 201
             array(),
191 202
             array());
192 203
 
204
+        $content      = $response->getContent();
205
+
193 206
         $this->assertResponseStatus(404);
194 207
     }
195 208
 

+ 14
- 18
tests/ApiScopeTest.php View File

@@ -1,11 +1,23 @@
1 1
 <?php
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
2 14
 use Models\OAuth2\ApiScope;
3 15
 use Models\OAuth2\Api;
4
-
16
+use Tests\BrowserKitTestCase;
5 17
 /**
6 18
  * Class ApiScopeTest
7 19
  */
8
-class ApiScopeTest extends TestCase {
20
+final class ApiScopeTest extends BrowserKitTestCase {
9 21
 
10 22
     private $current_realm;
11 23
 
@@ -110,20 +122,4 @@ class ApiScopeTest extends TestCase {
110 122
 
111 123
     }
112 124
 
113
-    /**
114
-     * testUpdate
115
-     * @covers updates an existing scope
116
-     */
117
-    public function testUpdate(){
118
-
119
-    }
120
-
121
-    /**
122
-     * testUpdateStatus
123
-     * @covers updates status of an existing scope
124
-     */
125
-    public function testUpdateStatus(){
126
-
127
-    }
128
-
129 125
 } 

+ 15
- 3
tests/ApiTest.php View File

@@ -1,12 +1,24 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use Models\OAuth2\Api;
4 15
 use Models\OAuth2\ResourceServer;
5
-
16
+use Tests\TestCase;
17
+use Tests\BrowserKitTestCase;
6 18
 /**
7 19
  * Class ApiTest
8 20
  */
9
-class ApiTest extends TestCase {
21
+final class ApiTest extends BrowserKitTestCase {
10 22
 
11 23
 
12 24
     private $current_realm;

+ 17
- 8
tests/AssociationServiceTest.php View File

@@ -1,19 +1,28 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use OpenId\Services\OpenIdServiceCatalog;
4 15
 use OpenId\Helpers\AssociationFactory;
5 16
 use OpenId\OpenIdProtocol;
6 17
 use Utils\Services\UtilsServiceCatalog;
7 18
 use Utils\Exceptions\UnacquiredLockException;
8
-
9
-class AssociationServiceTest extends TestCase
19
+use Tests\BrowserKitTestCase;
20
+/**
21
+ * Class AssociationServiceTest
22
+ */
23
+final class AssociationServiceTest extends BrowserKitTestCase
10 24
 {
11 25
 
12
-    public function __construct()
13
-    {
14
-
15
-    }
16
-
17 26
     public function tearDown()
18 27
     {
19 28
         Mockery::close();

+ 54
- 0
tests/BrowserKitTestCase.php View File

@@ -0,0 +1,54 @@
1
+<?php namespace Tests;
2
+/**
3
+ * Copyright 2015 Openstack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Illuminate\Support\Facades\Artisan;
15
+use Illuminate\Support\Facades\Redis;
16
+use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
17
+/**
18
+ * Class TestCase
19
+ * @package Tests
20
+ */
21
+abstract class BrowserKitTestCase extends BaseTestCase
22
+{
23
+    use CreatesApplication;
24
+
25
+    private $redis;
26
+
27
+    /**
28
+     * The base URL to use while testing the application.
29
+     *
30
+     * @var string
31
+     */
32
+    protected $baseUrl = 'http://localhost';
33
+
34
+    public function setUp()
35
+    {
36
+        parent::setUp(); // Don't forget this!
37
+        $this->redis = Redis::connection();
38
+        $this->redis->flushall();
39
+        $this->prepareForTests();
40
+    }
41
+
42
+
43
+    /**
44
+     * Migrates the database and set the mailer to 'pretend'.
45
+     * This will cause the tests to run quickly.
46
+     *
47
+     */
48
+    protected function prepareForTests()
49
+    {
50
+        Artisan::call('migrate');
51
+        //Mail::pretend(true);
52
+        $this->seed('TestSeeder');
53
+    }
54
+}

+ 15
- 1
tests/CacheServiceStub.php View File

@@ -1,7 +1,21 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use Utils\Services\ICacheService;
4 15
 
16
+/**
17
+ * Class CacheServiceStub
18
+ */
5 19
 class CacheServiceStub implements ICacheService {
6 20
 
7 21
 	private static $cache = array();

+ 1
- 3
tests/ClientApiTest.php View File

@@ -11,16 +11,14 @@
11 11
 * See the License for the specific language governing permissions and
12 12
 * limitations under the License.
13 13
 **/
14
-
15 14
 use OAuth2\Models\IClient;
16 15
 use Auth\User;
17 16
 use Models\OAuth2\Client;
18 17
 use Illuminate\Support\Facades\Session;
19
-
20 18
 /**
21 19
  * Class ClientApiTest
22 20
  */
23
-class ClientApiTest extends TestCase {
21
+class ClientApiTest extends \Tests\BrowserKitTestCase {
24 22
 
25 23
     private $current_realm;
26 24
 

+ 1
- 3
tests/ClientPublicKeyApiTest.php View File

@@ -11,13 +11,11 @@
11 11
 * See the License for the specific language governing permissions and
12 12
 * limitations under the License.
13 13
 **/
14
-
15
-
16 14
 use jwk\JSONWebKeyTypes;
17 15
 use jwk\JSONWebKeyPublicKeyUseValues;
18 16
 use Models\OAuth2\Client;
19 17
 use jwa\JSONWebSignatureAndEncryptionAlgorithms;
20
-
18
+use Tests\TestCase;
21 19
 /**
22 20
  * Class ClientPublicKeyApiTest
23 21
  */

+ 34
- 0
tests/CreatesApplication.php View File

@@ -0,0 +1,34 @@
1
+<?php namespace Tests;
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Illuminate\Contracts\Console\Kernel;
15
+/**
16
+ * Trait CreatesApplication
17
+ * @package Tests
18
+ */
19
+trait CreatesApplication
20
+{
21
+    /**
22
+     * Creates the application.
23
+     *
24
+     * @return \Illuminate\Foundation\Application
25
+     */
26
+    public function createApplication()
27
+    {
28
+        $app = require __DIR__.'/../bootstrap/app.php';
29
+
30
+        $app->make(Kernel::class)->bootstrap();
31
+
32
+        return $app;
33
+    }
34
+}

+ 1
- 1
tests/CustomAuthProviderTest.php View File

@@ -18,7 +18,7 @@ use OpenId\Services\OpenIdServiceCatalog;
18 18
 use Auth\Repositories\IUserRepository;
19 19
 use Auth\Repositories\IMemberRepository;
20 20
 use Auth\IAuthenticationExtensionService;
21
-
21
+use Tests\TestCase;
22 22
 /**
23 23
  * Class CustomAuthProviderTest
24 24
  */

+ 13
- 2
tests/DiffieHellmanTest.php View File

@@ -1,10 +1,21 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2015 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use OpenId\Helpers\AssocHandleGenerator;
4 15
 use OpenId\Helpers\OpenIdCryptoHelper;
5 16
 use OpenId\Requests\OpenIdDHAssociationSessionRequest;
6 17
 use Zend\Crypt\PublicKey\DiffieHellman;
7
-
18
+use Tests\TestCase;
8 19
 /**
9 20
  * Class DiffieHellmanTest
10 21
  */

+ 17
- 2
tests/DiscoveryControllerTest.php View File

@@ -1,6 +1,21 @@
1 1
 <?php
2
-
3
-class DiscoveryControllerTest extends TestCase
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Tests\BrowserKitTestCase;
15
+/***
16
+ * Class DiscoveryControllerTest
17
+ */
18
+final class DiscoveryControllerTest extends BrowserKitTestCase
4 19
 {
5 20
 
6 21
     public function testIdpDiscovery()

+ 21
- 0
tests/Feature/ExampleTest.php View File

@@ -0,0 +1,21 @@
1
+<?php
2
+
3
+namespace Tests\Feature;
4
+
5
+use Tests\TestCase;
6
+use Illuminate\Foundation\Testing\RefreshDatabase;
7
+
8
+class ExampleTest extends TestCase
9
+{
10
+    /**
11
+     * A basic test example.
12
+     *
13
+     * @return void
14
+     */
15
+    public function testBasicTest()
16
+    {
17
+        $response = $this->get('/');
18
+
19
+        $response->assertStatus(200);
20
+    }
21
+}

+ 1
- 3
tests/OAuth2ProtectedApiTest.php View File

@@ -11,13 +11,11 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
15 14
 use OAuth2\OAuth2Protocol;
16 15
 use Auth\User;
17 16
 use Utils\Services\IAuthService;
18 17
 use Illuminate\Support\Facades\Session;
19 18
 use Illuminate\Support\Facades\Config;
20
-
21 19
 /**
22 20
  * Class OAuth2ProtectedApiTest
23 21
  */
@@ -67,7 +65,7 @@ abstract class OAuth2ProtectedApiTest extends OpenStackIDBaseTest {
67 65
             OAuth2Protocol::OAuth2Protocol_AccessType => OAuth2Protocol::OAuth2Protocol_AccessType_Offline,
68 66
         );
69 67
 
70
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
68
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
71 69
 
72 70
         $response = $this->action("POST", "OAuth2\OAuth2ProviderController@auth",
73 71
             $params,

+ 18
- 18
tests/OAuth2ProtocolTest.php View File

@@ -17,7 +17,7 @@ use OAuth2\OAuth2Protocol;
17 17
 use Utils\Services\IAuthService;
18 18
 use Utils\Services\UtilsServiceCatalog;
19 19
 use Illuminate\Support\Facades\Session;
20
-
20
+use Illuminate\Support\Facades\Config;
21 21
 /**
22 22
  * Class OAuth2ProtocolTest
23 23
  * Test Suite for OAuth2 Protocol
@@ -191,7 +191,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
191 191
             OAuth2Protocol::OAuth2Protocol_AccessType => OAuth2Protocol::OAuth2Protocol_AccessType_Offline,
192 192
         );
193 193
 
194
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
194
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
195 195
 
196 196
         $response = $this->action("POST", "OAuth2\OAuth2ProviderController@auth",
197 197
             $params,
@@ -271,7 +271,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
271 271
             OAuth2Protocol::OAuth2Protocol_AccessType => OAuth2Protocol::OAuth2Protocol_AccessType_Offline,
272 272
         );
273 273
 
274
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
274
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
275 275
 
276 276
         $response = $this->action("POST", "OAuth2\OAuth2ProviderController@auth",
277 277
             $params,
@@ -339,7 +339,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
339 339
             $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
340 340
             $client_secret = 'ITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhg';
341 341
 
342
-            Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
342
+            Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
343 343
 
344 344
             //do authorization ...
345 345
 
@@ -491,7 +491,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
491 491
             $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
492 492
             $client_secret = 'ITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhg';
493 493
 
494
-            Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
494
+            Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
495 495
 
496 496
             //do authorization ...
497 497
 
@@ -596,7 +596,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
596 596
             $client_secret = 'ITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhg';
597 597
 
598 598
 
599
-            Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
599
+            Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
600 600
 
601 601
             //do authorization ...
602 602
 
@@ -710,7 +710,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
710 710
             $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
711 711
             $client_secret = 'ITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhg';
712 712
 
713
-            Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
713
+            Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
714 714
 
715 715
             //do authorization ...
716 716
 
@@ -822,7 +822,7 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
822 822
             $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
823 823
             $client_secret = 'ITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhgITc/6Y5N7kOtGKhg';
824 824
 
825
-            Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
825
+            Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
826 826
 
827 827
             //do authorization ...
828 828
 
@@ -905,9 +905,9 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
905 905
     public function testImplicitFlow()
906 906
     {
907 907
 
908
-        $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
908
+        $client_id = '1234/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
909 909
 
910
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
910
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
911 911
 
912 912
         $params = array(
913 913
             'client_id' => $client_id,
@@ -943,9 +943,9 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
943 943
 
944 944
     public function testTokenRevocation()
945 945
     {
946
-        $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
946
+        $client_id = '1234/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
947 947
 
948
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
948
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
949 949
 
950 950
         $params = array(
951 951
             'client_id' => $client_id,
@@ -997,9 +997,9 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
997 997
 
998 998
     public function testTokenRevocationInvalidClient()
999 999
     {
1000
-        $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1000
+        $client_id = '1234/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1001 1001
 
1002
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1002
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1003 1003
 
1004 1004
         $params = array(
1005 1005
             'client_id' => $client_id,
@@ -1052,9 +1052,9 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
1052 1052
     public function testTokenRevocationInvalidHint()
1053 1053
     {
1054 1054
 
1055
-        $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1055
+        $client_id = '1234/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1056 1056
 
1057
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1057
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1058 1058
 
1059 1059
         $params = array(
1060 1060
             'client_id' => $client_id,
@@ -1107,9 +1107,9 @@ final class OAuth2ProtocolTest extends OpenStackIDBaseTest
1107 1107
     public function testTokenRevocationInvalidToken()
1108 1108
     {
1109 1109
 
1110
-        $client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1110
+        $client_id = '1234/Vcvr6fvQbH4HyNgwKlfSyQ3x.openstack.client';
1111 1111
 
1112
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1112
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1113 1113
 
1114 1114
         $params = array(
1115 1115
             'client_id' => $client_id,

+ 13
- 3
tests/OAuth2UserServiceApiTest.php View File

@@ -1,11 +1,21 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use OAuth2\ResourceServer\IUserService;
4
-
5 15
 /**
6 16
  * Class OAuth2UserServiceApiTest
7 17
  */
8
-class OAuth2UserServiceApiTest extends OAuth2ProtectedApiTest {
18
+final class OAuth2UserServiceApiTest extends OAuth2ProtectedApiTest {
9 19
 
10 20
 
11 21
     /**

+ 2
- 4
tests/OIDCProtocolTest.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * Copyright 2015 OpenStack Foundation
5 4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,7 +36,7 @@ use jwt\impl\UnsecuredJWT;
37 36
  * Class OIDCProtocolTest
38 37
  * http://openid.net/wordpress-content/uploads/2015/02/OpenID-Connect-Conformance-Profiles.pdf
39 38
  */
40
-class OIDCProtocolTest extends OpenStackIDBaseTest
39
+final class OIDCProtocolTest extends OpenStackIDBaseTest
41 40
 {
42 41
     /**
43 42
      * @var string
@@ -83,8 +82,7 @@ class OIDCProtocolTest extends OpenStackIDBaseTest
83 82
 
84 83
         $this->assertTrue(array_key_exists('error', $output));
85 84
         $this->assertTrue(!empty($output['error']));
86
-        $this->assertTrue($output['error'] === OAuth2Protocol::OAuth2Protocol_Error_Interaction_Required);
87
-
85
+        $this->assertTrue($output['error'] === OAuth2Protocol::OAuth2Protocol_Error_Login_Required);
88 86
     }
89 87
 
90 88
     public function testLoginWithTrailingSpace()

+ 23
- 11
tests/OpenIdProtocolTest.php View File

@@ -1,5 +1,16 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use Auth\User;
4 15
 use OpenId\Extensions\Implementations\OpenIdOAuth2Extension;
5 16
 use OpenId\Extensions\Implementations\OpenIdSREGExtension;
@@ -15,7 +26,7 @@ use OpenId\Extensions\Implementations\OpenIdSREGExtension_1_0;
15 26
  * Class OpenIdProtocolTest
16 27
  * Test Suite for OpenId Protocol
17 28
  */
18
-class OpenIdProtocolTest extends OpenStackIDBaseTest
29
+final class OpenIdProtocolTest extends OpenStackIDBaseTest
19 30
 {
20 31
     private $current_realm;
21 32
     private $g;
@@ -26,8 +37,9 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
26 37
     private $oauth2_client_secret;
27 38
     private $user;
28 39
 
29
-    public function __construct()
40
+    public function __construct($name = null, array $data = [], $dataName = '')
30 41
     {
42
+        parent::__construct($name, $data, $dataName);
31 43
         //DH openid values
32 44
         $this->g = '1';
33 45
         $this->private = '84009535308644335779530519631942543663544485189066558731295758689838227409144125540638118058012144795574289866857191302071807568041343083679600155026066530597177004145874642611724010339353151653679189142289183802715816551715563883085859667759854344959305451172754264893136955464706052993052626766687910313992';
@@ -428,7 +440,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
428 440
         $this->assertTrue(isset($openid_response['enc_mac_key']));
429 441
         $this->assertTrue(isset($openid_response['expires_in']));
430 442
 
431
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
443
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
432 444
 
433 445
         $params = array(
434 446
             OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_NS) => OpenIdProtocol::OpenID2MessageType,
@@ -539,7 +551,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
539 551
     public function testAuthenticationCheckImmediateAuthenticationPrivateSession()
540 552
     {
541 553
         //set login info
542
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
554
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
543 555
 
544 556
         //add trusted site
545 557
         $site = new OpenIdTrustedSite;
@@ -598,7 +610,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
598 610
     public function testAuthenticationCheckImmediateAuthenticationPrivateSession_SetupNeeded()
599 611
     {
600 612
         //set login info
601
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
613
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
602 614
         $this->user->trusted_sites()->delete();
603 615
         $params = array(
604 616
             OpenIdProtocol::param(OpenIdProtocol::OpenIDProtocol_NS) => OpenIdProtocol::OpenID2MessageType,
@@ -634,7 +646,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
634 646
     {
635 647
 
636 648
         //set login info
637
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
649
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
638 650
         $sreg_required_params = array('email', 'fullname', 'nickname');
639 651
 
640 652
         $params = array(
@@ -708,7 +720,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
708 720
     {
709 721
 
710 722
         //set login info
711
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
723
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
712 724
         $sreg_required_params = array('email', 'fullname');
713 725
 
714 726
         $params = array(
@@ -782,7 +794,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
782 794
     {
783 795
 
784 796
         //set login info
785
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
797
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowForever);
786 798
         $sreg_required_params = array('email', 'fullname');
787 799
 
788 800
         $params = array(
@@ -982,7 +994,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
982 994
     {
983 995
 
984 996
         //set login info
985
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
997
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
986 998
 
987 999
         $scope = array(
988 1000
             sprintf('%s/resource-server/read', $this->current_realm),
@@ -1063,7 +1075,7 @@ class OpenIdProtocolTest extends OpenStackIDBaseTest
1063 1075
     {
1064 1076
 
1065 1077
         //set login info
1066
-        Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1078
+        Session::put("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
1067 1079
 
1068 1080
         $scope = array(
1069 1081
             sprintf('%s/resource-server/read', $this->current_realm),

+ 2
- 3
tests/OpenStackIDBaseTest.php View File

@@ -11,14 +11,13 @@
11 11
  * See the License for the specific language governing permissions and
12 12
  * limitations under the License.
13 13
  **/
14
-
15 14
 use Illuminate\Support\Facades\Schema;
16 15
 use Illuminate\Support\Facades\DB;
17
-
16
+use Tests\BrowserKitTestCase;
18 17
 /**
19 18
  * Class OpenStackIDBaseTest
20 19
  */
21
-abstract class OpenStackIDBaseTest extends TestCase {
20
+abstract class OpenStackIDBaseTest extends BrowserKitTestCase {
22 21
 
23 22
     protected function prepareForTests()
24 23
     {

+ 14
- 3
tests/ResourceServerApiTest.php View File

@@ -1,15 +1,26 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use Models\OAuth2\ResourceServer;
4 15
 use Illuminate\Support\Facades\Config;
5 16
 use Auth\User;
6 17
 use Illuminate\Support\Facades\Session;
7
-
18
+use Tests\BrowserKitTestCase;
8 19
 /**
9 20
  * Class ResourceServerApiTest
10 21
  * Test ResourceServer REST API
11 22
  */
12
-class ResourceServerApiTest extends TestCase
23
+final class ResourceServerApiTest extends BrowserKitTestCase
13 24
 {
14 25
 
15 26
     private $current_realm;

+ 0
- 1
tests/StubServerConfigurationService.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * Copyright 2016 OpenStack Foundation
5 4
  * Licensed under the Apache License, Version 2.0 (the "License");

+ 17
- 52
tests/TestCase.php View File

@@ -1,57 +1,22 @@
1
-<?php
2
-
3
-use Illuminate\Support\Facades\Redis;
4
-
1
+<?php namespace Tests;
2
+/**
3
+ * Copyright 2015 Openstack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
14
+use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
5 15
 /**
6 16
  * Class TestCase
17
+ * @package Tests
7 18
  */
8
-class TestCase extends Illuminate\Foundation\Testing\TestCase
19
+abstract class TestCase extends BaseTestCase
9 20
 {
10
-    private $redis;
11
-
12
-    /**
13
-     * The base URL to use while testing the application.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $baseUrl = 'http://localhost';
18
-
19
-    /**
20
-     * Creates the application.
21
-     *
22
-     * @return \Illuminate\Foundation\Application
23
-     */
24
-    public function createApplication()
25
-    {
26
-        $app = require __DIR__.'/../bootstrap/app.php';
27
-
28
-        $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
29
-
30
-        return $app;
31
-    }
32
-
33
-    public function __construct(){
34
-
35
-    }
36
-
37
-    public function setUp()
38
-    {
39
-        parent::setUp(); // Don't forget this!
40
-        $this->redis = Redis::connection();
41
-        $this->redis->flushall();
42
-        $this->prepareForTests();
43
-    }
44
-
45
-
46
-    /**
47
-     * Migrates the database and set the mailer to 'pretend'.
48
-     * This will cause the tests to run quickly.
49
-     *
50
-     */
51
-    protected function prepareForTests()
52
-    {
53
-        Artisan::call('migrate');
54
-        //Mail::pretend(true);
55
-        $this->seed('TestSeeder');
56
-    }
21
+    use CreatesApplication;
57 22
 }

+ 5
- 2
tests/TokenRepositoryTest.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * Copyright 2016 OpenStack Foundation
5 4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +11,11 @@
12 11
  * See the License for the specific language governing permissions and
13 12
  * limitations under the License.
14 13
  **/
15
-class TokenRepositoryTest extends TestCase
14
+use Tests\TestCase;
15
+/**
16
+ * Class TokenRepositoryTest
17
+ */
18
+final class TokenRepositoryTest extends TestCase
16 19
 {
17 20
     public function testAccessTokenRepository(){
18 21
         $repository = $this->app[\OAuth2\Repositories\IAccessTokenRepository::class];

+ 16
- 15
tests/TrustedSitesServiceTest.php View File

@@ -1,20 +1,27 @@
1 1
 <?php
2
-
2
+/**
3
+ * Copyright 2016 OpenStack Foundation
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ **/
3 14
 use OpenId\Services\OpenIdServiceCatalog;
4 15
 use Utils\Services\IAuthService;
5 16
 use OpenId\Repositories\IOpenIdTrustedSiteRepository;
6 17
 use OpenId\Models\IOpenIdUser;
7 18
 use Auth\User;
8 19
 use Repositories\EloquentOpenIdTrustedSiteRepository;
9
-use Way\Tests\Factory;
20
+use Tests\BrowserKitTestCase;
10 21
 /**
11 22
  * Class TrustedSitesServiceTest
12 23
  */
13
-class TrustedSitesServiceTest extends TestCase {
14
-
15
-	public function __construct()
16
-    {