diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml index 4f14a92c8..1c61ecb8b 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml @@ -82,7 +82,7 @@ services: self_service.service.application: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\ApplicationHelper arguments: - $kernelRootDir: "%kernel.root_dir%" + $kernelProjectDir: "%kernel.project_dir%" self_service.service.identity: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\IdentityService diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/ApplicationHelper.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/ApplicationHelper.php index cdce984a3..ad0a03250 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/ApplicationHelper.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/ApplicationHelper.php @@ -22,15 +22,15 @@ class ApplicationHelper { - private $kernelRootDir; + private $kernelProjectDir; /** - * @param string $kernelRootDir + * @param string $kernelProjectDir */ - public function __construct($kernelRootDir) + public function __construct($kernelProjectDir) { - Assert::string($kernelRootDir, 'Kernel root directory must have a string value'); - $this->kernelRootDir = $kernelRootDir; + Assert::string($kernelProjectDir, 'Kernel project directory must have a string value'); + $this->kernelProjectDir = $kernelProjectDir; } /** @@ -44,7 +44,7 @@ public function __construct($kernelRootDir) public function getApplicationVersion() { // The buildPath (version string) is the installation directory of the project. And is derived from the - // kernel.root_dir (which is the app folder). - return basename(realpath($this->kernelRootDir . '/../')); + // kernel.project_dir (which is the app folder). + return basename(realpath($this->kernelProjectDir)); } } diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/RemoteVettingServiceTestTest.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/RemoteVettingServiceTestTest.php index 8b2c9b672..efe4b38a2 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/RemoteVettingServiceTestTest.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/RemoteVettingServiceTestTest.php @@ -45,72 +45,20 @@ class RemoteVettingServiceTest extends TestCase * @var RemoteVettingService */ private $service; - - - private $publicKey = <<publicKey = file_get_contents($kernelRootPath. '/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Resources/encryption.crt'); + $this->privateKey = file_get_contents($kernelRootPath . '/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Resources/encryption.key'); $this->remoteVettingConfiguration = m::mock(RemoteVettingConfiguration::class); - $this->applicationHelper = m::mock(ApplicationHelper::class); + $this->applicationHelper = new ApplicationHelper($kernelRootPath); $this->fakeIdentityWriter = new FakeIdentityWriter(); $this->logger = new TestLogger(); $session = new Session(new MockFileSessionStorage()); - $this->identityEncrypter = new IdentityEncrypter($this->remoteVettingConfiguration, $this->fakeIdentityWriter); + $identityEncrypter = new IdentityEncrypter($this->remoteVettingConfiguration, $this->fakeIdentityWriter); $this->attributeMapper = new AttributeMapper($this->remoteVettingConfiguration); - $this->remoteVettingContext = new RemoteVettingContext($session); + $remoteVettingContext = new RemoteVettingContext($session); $now = new DateTime(); $mockTime = new DateTime('@1614004537',$now->getTimezone()); DateTimeHelper::setCurrentTime($mockTime); $this->service = new RemoteVettingService( - $this->remoteVettingContext, + $remoteVettingContext, $this->attributeMapper, - $this->identityEncrypter, + $identityEncrypter, $this->applicationHelper, $this->logger ); @@ -192,9 +141,6 @@ public function test_happy_flow() 'familyName' => 'familyName', ]); - $this->applicationHelper->shouldReceive('getApplicationVersion') - ->andReturn('1.0.0'); - $this->remoteVettingConfiguration->shouldReceive("getPublicKey") ->andReturn($this->publicKey); @@ -214,7 +160,7 @@ public function test_happy_flow() // test encrypted result $result = Decrypter::decrypt($this->fakeIdentityWriter->getData(), $this->privateKey); - $this->assertSame('{"attribute-data":{"local-attributes":{"nameId":"john.doe@example.com","attributes":{"email":["john@example.com"],"firstName":["Johnie"],"familyName":["Doe"],"telephone":["0612345678"]}},"remote-attributes":{"nameId":"john.doe@example.com","attributes":{"emailAddress":["johndoe@example.com"],"givenName":["John"],"familyName":["Doe"],"fullName":["John Doe"]}},"matching-results":{"email":{"local":{"name":"email","value":["john@example.com"]},"remote":{"name":"emailAddress","value":["johndoe@example.com"]},"is-valid":false,"remarks":""},"firstName":{"local":{"name":"firstName","value":["Johnie"]},"remote":{"name":"givenName","value":["John"]},"is-valid":false,"remarks":""},"familyName":{"local":{"name":"familyName","value":["Doe"]},"remote":{"name":"familyName","value":["Doe"]},"is-valid":false,"remarks":""}}},"remarks":"This seems a pretty decent match","name-id":"john.doe@example.com","institution":"stepup.example.com","remote-vetting-source":"mock","application-version":"1.0.0","time":"2021-02-22T14:35:37+00:00"}', $result); + $this->assertSame('{"attribute-data":{"local-attributes":{"nameId":"john.doe@example.com","attributes":{"email":["john@example.com"],"firstName":["Johnie"],"familyName":["Doe"],"telephone":["0612345678"]}},"remote-attributes":{"nameId":"john.doe@example.com","attributes":{"emailAddress":["johndoe@example.com"],"givenName":["John"],"familyName":["Doe"],"fullName":["John Doe"]}},"matching-results":{"email":{"local":{"name":"email","value":["john@example.com"]},"remote":{"name":"emailAddress","value":["johndoe@example.com"]},"is-valid":false,"remarks":""},"firstName":{"local":{"name":"firstName","value":["Johnie"]},"remote":{"name":"givenName","value":["John"]},"is-valid":false,"remarks":""},"familyName":{"local":{"name":"familyName","value":["Doe"]},"remote":{"name":"familyName","value":["Doe"]},"is-valid":false,"remarks":""}}},"remarks":"This seems a pretty decent match","name-id":"john.doe@example.com","institution":"stepup.example.com","remote-vetting-source":"mock","application-version":"Stepup-SelfService","time":"2021-02-22T14:35:37+00:00"}', $result); // test logs $this->assertSame([