Oefenweb /
cakephp-uni-login
| 1 | <?php |
||
| 2 | App::uses('TestProviderController', 'UniLogin.Controller'); |
||
| 3 | App::uses('UniLoginUtil', 'UniLogin.Lib'); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * TestProviderController Test Case. |
||
| 7 | * |
||
| 8 | */ |
||
| 9 | class TestProviderControllerTest extends ControllerTestCase { |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | /** |
||
| 12 | * Contains the original plugin configuration. |
||
| 13 | * |
||
| 14 | * @var array|null |
||
| 15 | */ |
||
| 16 | protected $_restore = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * setUp method |
||
| 20 | * |
||
| 21 | * @return void |
||
| 22 | */ |
||
| 23 | public function setUp() { |
||
| 24 | parent::setUp(); |
||
| 25 | |||
| 26 | $this->_restore = Configure::read('UniLogin.testProvider'); |
||
|
0 ignored issues
–
show
The type
Configure was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 27 | |||
| 28 | Configure::write('UniLogin.testProvider.defaultRedirectUrl', 'http://www.example.com/redirectUrl'); |
||
| 29 | Configure::write('UniLogin.testProvider.applicationId', 'myApplicationId'); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * tearDown method |
||
| 34 | * |
||
| 35 | * @return void |
||
| 36 | */ |
||
| 37 | public function tearDown() { |
||
| 38 | Configure::write('UniLogin.testProvider', $this->_restore); |
||
| 39 | |||
| 40 | parent::tearDown(); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Tests `/uni_login/test_provider/authenticate`. |
||
| 45 | * |
||
| 46 | * Default URL. |
||
| 47 | * |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function testAuthenticateDefaultUrl() { |
||
| 51 | $defaultRedirectUrl = 'http://www.example.com/redirectUrl'; |
||
| 52 | |||
| 53 | $this->testAction('/uni_login/test_provider/authenticate', [ |
||
| 54 | 'data' => [ |
||
| 55 | 'id' => 'myApplicationId', |
||
| 56 | ], |
||
| 57 | 'method' => 'get', |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $this->assertContains($defaultRedirectUrl, $this->headers['Location']); |
||
| 61 | $this->assertContains('user=', $this->headers['Location']); |
||
| 62 | $this->assertContains('timestamp=', $this->headers['Location']); |
||
| 63 | $this->assertContains('auth=', $this->headers['Location']); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Tests `/uni_login/test_provider/authenticate`. |
||
| 68 | * |
||
| 69 | * Default URL without application ID. |
||
| 70 | * |
||
| 71 | * @return void |
||
| 72 | */ |
||
| 73 | public function testAuthenticateDefaultUrlWithoutApplicationId() { |
||
| 74 | $defaultRedirectUrl = 'http://www.example.com/redirectUrl'; |
||
| 75 | |||
| 76 | $this->testAction('/uni_login/test_provider/authenticate', [ |
||
| 77 | 'method' => 'get', |
||
| 78 | ]); |
||
| 79 | |||
| 80 | $this->assertContains($defaultRedirectUrl, $this->headers['Location']); |
||
| 81 | $this->assertNotContains('user=', $this->headers['Location']); |
||
| 82 | $this->assertNotContains('timestamp=', $this->headers['Location']); |
||
| 83 | $this->assertNotContains('auth=', $this->headers['Location']); |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Tests `/uni_login/test_provider/authenticate`. |
||
| 88 | * |
||
| 89 | * Redirect URL parameter. |
||
| 90 | * |
||
| 91 | * @return void |
||
| 92 | */ |
||
| 93 | public function testAuthenticateRedirectUrlParameter() { |
||
| 94 | $url = 'http://www.mydomain.com'; |
||
| 95 | $path = UniLoginUtil::encodeUrl($url); |
||
| 96 | $auth = UniLoginUtil::calculateUrlFingerprint($url); |
||
| 97 | $this->testAction('/uni_login/test_provider/authenticate', [ |
||
| 98 | 'data' => [ |
||
| 99 | 'id' => 'myApplicationId', |
||
| 100 | 'path' => $path, |
||
| 101 | 'auth' => $auth, |
||
| 102 | ], |
||
| 103 | 'method' => 'get', |
||
| 104 | ]); |
||
| 105 | |||
| 106 | $this->assertContains($url, $this->headers['Location']); |
||
| 107 | $this->assertContains('user=', $this->headers['Location']); |
||
| 108 | $this->assertContains('timestamp=', $this->headers['Location']); |
||
| 109 | $this->assertContains('auth=', $this->headers['Location']); |
||
| 110 | } |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Tests `/uni_login/test_provider/authenticate`. |
||
| 114 | * |
||
| 115 | * Redirect URL parameter without application ID. |
||
| 116 | * |
||
| 117 | * @return void |
||
| 118 | */ |
||
| 119 | public function testAuthenticateRedirectUrlParameterWithoutApplicationId() { |
||
| 120 | $url = 'http://www.mydomain.com'; |
||
| 121 | $path = UniLoginUtil::encodeUrl($url); |
||
| 122 | $auth = UniLoginUtil::calculateUrlFingerprint($url); |
||
| 123 | $this->testAction('/uni_login/test_provider/authenticate', [ |
||
| 124 | 'data' => [ |
||
| 125 | 'path' => $path, |
||
| 126 | 'auth' => $auth, |
||
| 127 | ], |
||
| 128 | 'method' => 'get' |
||
| 129 | ]); |
||
| 130 | |||
| 131 | $this->assertContains($url, $this->headers['Location']); |
||
| 132 | $this->assertNotContains('user=', $this->headers['Location']); |
||
| 133 | $this->assertNotContains('timestamp=', $this->headers['Location']); |
||
| 134 | $this->assertNotContains('auth=', $this->headers['Location']); |
||
| 135 | } |
||
| 136 | } |
||
| 137 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths