Oefenweb /
cakephp-uni-login
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * TestUniLoginControllerTest Test Case. |
||
| 5 | * |
||
| 6 | */ |
||
| 7 | class TestUniLoginControllerTest extends ControllerTestCase { |
||
|
0 ignored issues
–
show
|
|||
| 8 | |||
| 9 | /** |
||
| 10 | * Contains the original plugin configuration. |
||
| 11 | * |
||
| 12 | * @var array|null |
||
| 13 | */ |
||
| 14 | protected $_restore = null; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * setUp method |
||
| 18 | * |
||
| 19 | * @return void |
||
| 20 | */ |
||
| 21 | public function setUp() { |
||
| 22 | parent::setUp(); |
||
| 23 | |||
| 24 | $this->_restore = Configure::read('UniLogin'); |
||
|
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...
|
|||
| 25 | |||
| 26 | Configure::write('UniLogin.application.completeUrl', '/completeUrl'); |
||
| 27 | Configure::write('UniLogin.application.secret', 'secret'); |
||
| 28 | Configure::write('UniLogin.provider.applicationId', 123456789); |
||
| 29 | Configure::write('UniLogin.provider.url', 'http://www.example.org/redirectUrl'); |
||
| 30 | Configure::write('UniLogin.provider.secret', 'abc123'); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * tearDown method |
||
| 35 | * |
||
| 36 | * @return void |
||
| 37 | */ |
||
| 38 | public function tearDown() { |
||
| 39 | Configure::write('UniLogin', $this->_restore); |
||
| 40 | |||
| 41 | parent::tearDown(); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Tests `/uni_login/uni_login/login`. |
||
| 46 | * |
||
| 47 | * @return void |
||
| 48 | */ |
||
| 49 | public function testLogin() { |
||
| 50 | $this->testAction('/uni_login/uni_login/login', ['method' => 'get']); |
||
| 51 | |||
| 52 | $this->assertStringStartsWith('http://www.example.org/redirectUrl?path=', $this->headers['Location']); |
||
| 53 | $this->assertStringEndsWith('&id=123456789', $this->headers['Location']); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Tests `/uni_login/uni_login/callback`. |
||
| 58 | * |
||
| 59 | * Not valid. |
||
| 60 | * |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | public function testCallbackNotValid() { |
||
| 64 | $UniLogin = $this->generate('UniLogin', ['methods' => ['_dispatch']]); |
||
| 65 | |||
| 66 | $data = ['validated' => false]; |
||
| 67 | $hmac = UniLoginUtil::hmac($data); |
||
| 68 | |||
| 69 | $UniLogin->expects($this->once()) |
||
| 70 | ->method('_dispatch') |
||
| 71 | ->with('/completeUrl', array_merge($data, ['hmac' => $hmac])); |
||
| 72 | |||
| 73 | $this->testAction('/uni_login/uni_login/callback', ['method' => 'get']); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Tests `/uni_login/uni_login/callback`. |
||
| 78 | * |
||
| 79 | * Valid. |
||
| 80 | * |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | public function testCallbackValid() { |
||
| 84 | $UniLogin = $this->generate('UniLogin', ['methods' => ['_dispatch']]); |
||
| 85 | |||
| 86 | $timestamp = time(); |
||
| 87 | $formattedTimestamp = UniLoginUtil::getFormattedTimestamp($timestamp); |
||
| 88 | $user = 'user'; |
||
| 89 | $fingerprint = UniLoginUtil::calculateFingerprint($formattedTimestamp, $user); |
||
| 90 | $data = [ |
||
| 91 | 'user' => $user, |
||
| 92 | 'timestamp' => $formattedTimestamp, |
||
| 93 | 'auth' => $fingerprint, |
||
| 94 | 'validated' => true, |
||
| 95 | ]; |
||
| 96 | $hmac = UniLoginUtil::hmac($data); |
||
| 97 | |||
| 98 | $UniLogin->expects($this->once()) |
||
| 99 | ->method('_dispatch') |
||
| 100 | ->with('/completeUrl', array_merge($data, ['hmac' => $hmac])); |
||
| 101 | |||
| 102 | $this->testAction('/uni_login/uni_login/callback', ['method' => 'get', 'data' => $data]); |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
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