From 1778271790a938a3b183ba43a537c0616045fc0c Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Mon, 12 Aug 2024 09:40:59 +0200 Subject: [PATCH] Add the revisionnote to the Manage JSON --- .../Application/Metadata/JsonGenerator.php | 5 +- .../Metadata/JsonGeneratorStrategy.php | 3 +- ...thClientCredentialsClientJsonGenerator.php | 3 +- .../Metadata/OidcngJsonGenerator.php | 4 +- .../OidcngResourceServerJsonGenerator.php | 4 +- .../Manage/Client/PublishEntityClient.php | 1 + .../Metadata/JsonGeneratorStrategyTest.php | 6 +- .../Metadata/JsonGeneratorTest.php | 55 +++++++++++++++---- .../Metadata/OidcngJsonGeneratorTest.php | 34 +++++++++--- .../OidcngResourceServerJsonGeneratorTest.php | 15 ++++- 10 files changed, 91 insertions(+), 39 deletions(-) diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php index 0da0f3526..cba74a1ca 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php @@ -77,7 +77,7 @@ public function generateForExistingEntity( 'type' => 'saml20_sp', 'id' => $entity->getId(), ]; - $data['revisionnote'] = (string) new EntityEditRevisionNote( + $data['pathUpdates']['revisionnote'] = (string) new EntityEditRevisionNote( $entity->getComments(), $contact->getDisplayName(), $contact->getEmailAddress(), @@ -125,8 +125,6 @@ private function generateDataForNewEntity(ManageEntity $entity, string $workflow $metadata += $this->generateAclData($entity); $metadata['metadataurl'] = $entity->getMetaData()->getMetadataUrl(); - $metadata['revisionnote'] = $entity->getRevisionNote(); - return $metadata; } @@ -154,7 +152,6 @@ private function generateDataForExistingEntity( } $metadata = $this->generateArp($metadata, $entity); $metadata['state'] = $workflowState; - $metadata['revisionnote'] = $entity->getRevisionNote(); // When publishing to production, the coin:exclude_from_push must be present and set to '1'. This prevents the // entity from being pushed to EngineBlock. Once the entity is checked a final time, the flag is set to 0 diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGeneratorStrategy.php b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGeneratorStrategy.php index 9a16d8f3d..fb77e2308 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGeneratorStrategy.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGeneratorStrategy.php @@ -69,10 +69,11 @@ public function generateForExistingEntity( ManageEntity $entity, EntityDiff $differences, string $workflowState, + Contact $contact, string $updatedPart = '', ): array { return $this->getStrategy($entity->getProtocol()->getProtocol()) - ->generateForExistingEntity($entity, $differences, $workflowState, $updatedPart); + ->generateForExistingEntity($entity, $differences, $workflowState, $contact, $updatedPart); } public function generateEntityChangeRequest( diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OauthClientCredentialsClientJsonGenerator.php b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OauthClientCredentialsClientJsonGenerator.php index 1daeb2c97..9c2e0408b 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OauthClientCredentialsClientJsonGenerator.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OauthClientCredentialsClientJsonGenerator.php @@ -81,7 +81,7 @@ public function generateForExistingEntity( 'type' => 'oidc10_rp', 'id' => $entity->getId(), ]; - $data['revisionnote'] = (string) new EntityEditRevisionNote( + $data['pathUpdates']['revisionnote'] = (string) new EntityEditRevisionNote( $entity->getComments(), $contact->getDisplayName(), $contact->getEmailAddress(), @@ -155,7 +155,6 @@ private function generateDataForExistingEntity( $this->privacyQuestionsMetadataGenerator->withMetadataPrefix(); $metadata += $this->privacyQuestionsMetadataGenerator->build($entity); - $metadata['revisionnote'] = $entity->getRevisionNote(); return $metadata; } } diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngJsonGenerator.php b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngJsonGenerator.php index 3fd0fbef6..c78232c4f 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngJsonGenerator.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngJsonGenerator.php @@ -80,7 +80,7 @@ public function generateForExistingEntity( 'type' => 'oidc10_rp', 'id' => $entity->getId(), ]; - $data['revisionnote'] = (string) new EntityEditRevisionNote( + $data['pathUpdates']['revisionnote'] = (string) new EntityEditRevisionNote( $entity->getComments(), $contact->getDisplayName(), $contact->getEmailAddress(), @@ -159,8 +159,6 @@ private function generateDataForExistingEntity( $this->privacyQuestionsMetadataGenerator->withMetadataPrefix(); $metadata += $this->privacyQuestionsMetadataGenerator->build($entity); - $metadata['revisionnote'] = $entity->getRevisionNote(); - return $metadata; } } diff --git a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngResourceServerJsonGenerator.php b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngResourceServerJsonGenerator.php index e4e675687..57fd3e089 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngResourceServerJsonGenerator.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/Metadata/OidcngResourceServerJsonGenerator.php @@ -77,7 +77,7 @@ public function generateForExistingEntity( 'active' => true, 'id' => $entity->getId(), ]; - $data['revisionnote'] = (string) new EntityEditRevisionNote( + $data['pathUpdates']['revisionnote'] = (string) new EntityEditRevisionNote( $entity->getComments(), $contact->getDisplayName(), $contact->getEmailAddress(), @@ -143,8 +143,6 @@ private function generateDataForExistingEntity( $this->privacyQuestionsMetadataGenerator->withMetadataPrefix(); $metadata += $this->privacyQuestionsMetadataGenerator->build($entity); - $metadata['revisionnote'] = $entity->getRevisionNote(); - return $metadata; } diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/PublishEntityClient.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/PublishEntityClient.php index 28885c931..6c8308748 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/PublishEntityClient.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/PublishEntityClient.php @@ -73,6 +73,7 @@ public function publish( $entity, $diff, $this->manageConfig->getPublicationStatus()->getStatus(), + $contact, $part ) ); diff --git a/tests/unit/Application/Metadata/JsonGeneratorStrategyTest.php b/tests/unit/Application/Metadata/JsonGeneratorStrategyTest.php index e48bb44bc..c51068bb0 100644 --- a/tests/unit/Application/Metadata/JsonGeneratorStrategyTest.php +++ b/tests/unit/Application/Metadata/JsonGeneratorStrategyTest.php @@ -87,11 +87,11 @@ public function test_generate_for_existing_entity() $entity->shouldReceive('getProtocol->getProtocol')->andReturn('saml'); $diff = m::mock(EntityDiff::class); - $result = $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted'); + $result = $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted', m::mock(Contact::class)); $this->assertIsArray($result); $entity->shouldReceive('getProtocol->getProtocol')->andReturn('oidcng'); - $result = $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted'); + $result = $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted', m::mock(Contact::class)); $this->assertIsArray($result); } @@ -104,6 +104,6 @@ public function test_add_invalid_strategy() $this->expectException(JsonGeneratorStrategyNotFoundException::class); $this->expectExceptionMessage('The requested JsonGenerator for protocol "saml30" is not registered'); $diff = m::mock(EntityDiff::class); - $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted'); + $this->strategy->generateForExistingEntity($entity, $diff, 'prodaccepted', m::mock(Contact::class)); } } diff --git a/tests/unit/Application/Metadata/JsonGeneratorTest.php b/tests/unit/Application/Metadata/JsonGeneratorTest.php index bec31b8cf..068e0bdf7 100644 --- a/tests/unit/Application/Metadata/JsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/JsonGeneratorTest.php @@ -133,8 +133,10 @@ public function test_it_can_build_saml_metadata_for_existing_entities() $entity = $this->createManageEntity(); $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - - $metadata = $generator->generateForExistingEntity($entity, $diff, 'testaccepted'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('Alec Ann'); + $contact->shouldReceive('getEmailAddress')->andReturn('aa@example.com'); + $metadata = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact); $metadata = $metadata['pathUpdates']; $this->assertArrayNotHasKey('active', $metadata); @@ -142,7 +144,8 @@ public function test_it_can_build_saml_metadata_for_existing_entities() $this->assertEquals('http://entityid', $metadata['entityid']); $this->assertEquals('http://metadata', $metadata['metadataurl']); - $this->assertEquals('revisionnote', $metadata['revisionnote']); + $this->assertStringContainsString('Entity edited by user Alec Ann with email address "aa@example.com"', $metadata['revisionnote']); + $this->assertStringContainsString('revisionnote', $metadata['revisionnote']); $this->assertEquals(['arp' => 'arp'], $metadata['arp']); @@ -229,7 +232,11 @@ public function test_it_can_build_saml_data_for_existing_entities() $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact); $expected = array ( 'pathUpdates' => @@ -240,13 +247,13 @@ public function test_it_can_build_saml_data_for_existing_entities() 'metaDataFields.name:en' => 'Test Entity EN', 'metaDataFields.name:nl' => 'Test Entity NL', 'state' => 'testaccepted', - 'revisionnote' => 'revisionnote', 'metaDataFields.contacts:2:givenName' => 'John Doe', 'metaDataFields.coin:exclude_from_push' => '0', 'privacy' => 'privacy', ), 'type' => 'saml20_sp', 'id' => 'manageId', + ); $this->addEmptyAscLocations(1, 'metaDataFields.', $expected['pathUpdates']); @@ -254,6 +261,9 @@ public function test_it_can_build_saml_data_for_existing_entities() $expected['pathUpdates']['metaDataFields.AssertionConsumerService:0:Binding'] = Constants::BINDING_HTTP_POST; $expected['pathUpdates']['metaDataFields.AssertionConsumerService:0:Location'] = 'http://acs'; + $this->assertStringContainsString('Entity edited by user John Doe with email address "jd@example.com"', $data['pathUpdates']['revisionnote']); + unset($data['pathUpdates']['revisionnote']); + $this->assertEquals($expected, $data); } @@ -269,7 +279,10 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_default_al $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact, 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(true, $data['pathUpdates']['allowedall']); @@ -289,7 +302,10 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_all( $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact, 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(true, $data['pathUpdates']['allowedall']); @@ -309,7 +325,10 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_none() $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact, 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(false, $data['pathUpdates']['allowedall']); @@ -330,7 +349,10 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_sing $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact, 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(false, $data['pathUpdates']['allowedall']); @@ -358,7 +380,10 @@ public function test_exclude_from_push_is_correctly_set() ->shouldReceive('isProduction') ->andReturn(true); - $data = $generator->generateForExistingEntity($entity, $diff, 'prodaccepted'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'prodaccepted', $contact); $this->assertEquals('1', $data['pathUpdates']['metaDataFields.coin:exclude_from_push']); } @@ -382,7 +407,10 @@ public function test_exclude_from_push_is_correctly_set_include() ->shouldReceive('isProduction') ->andReturn(true); - $data = $generator->generateForExistingEntity($entity, $diff, 'prodaccepted'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'prodaccepted', $contact); $this->assertEquals('0', $data['pathUpdates']['metaDataFields.coin:exclude_from_push']); } @@ -400,7 +428,10 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_mult $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $contact = m::mock(Contact::class); + $contact->shouldReceive('getDisplayName')->andReturn('John Doe'); + $contact->shouldReceive('getEmailAddress')->andReturn('jd@example.com'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $contact, 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(false, $data['pathUpdates']['allowedall']); diff --git a/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php b/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php index 3a5d9aefe..14f4639b1 100644 --- a/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php @@ -20,6 +20,7 @@ use Mockery as m; use Mockery\Adapter\Phpunit\MockeryTestCase; +use Mockery\MockInterface; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator\ArpGenerator; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator\PrivacyQuestionsMetadataGenerator; @@ -81,7 +82,14 @@ public function test_it_can_build_oidcng_entity_data_for_new_entities() $entity = $this->createManageEntity(); $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact()); + + $note = $data['pathUpdates']['revisionnote']; + // First test the revisionnote (date part is not tested, it is not using a static (test) clock so only the first part is tested, + $this->assertStringContainsString('Entity edited by user John Doe with email address "j.doe@example.com"', $note); + // Then remove the revisiononte from the data and expected data. + unset($data['pathUpdates']['revisionnote']); + $this->assertEquals( [ 'type' => 'oidc10_rp', @@ -94,7 +102,6 @@ public function test_it_can_build_oidcng_entity_data_for_new_entities() 'metaDataFields.contacts:2:surName' => 'Doe', 'metaDataFields.OrganizationName:nl' => 'Drop Supplies', 'metaDataFields.OrganizationDisplayName:en' => 'Drop Supplies', - 'revisionnote' => 'revisionnote', 'privacy' => 'privacy' ], ], @@ -117,8 +124,10 @@ public function test_it_can_build_oidcng_data_for_existing_entities() $entity = $this->createManageEntity(); $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact()); + $this->assertStringContainsString('Entity edited by user John Doe with email address "j.doe@example.com"', $data['pathUpdates']['revisionnote']); + unset($data['pathUpdates']['revisionnote']); $this->assertEquals( array( 'pathUpdates' => @@ -132,7 +141,6 @@ public function test_it_can_build_oidcng_data_for_existing_entities() 'allowedResourceServers' => [ ], - 'revisionnote' => 'revisionnote', 'privacy' => 'privacy' ), 'type' => 'oidc10_rp', @@ -155,7 +163,7 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_default_al $entity = $this->createManageEntity(); $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact(), 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(true, $data['pathUpdates']['allowedall']); @@ -179,7 +187,7 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_all( $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact(), 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(true, $data['pathUpdates']['allowedall']); @@ -203,7 +211,7 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_none() $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact(), 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); @@ -229,7 +237,7 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_sing ]); $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact(), 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(false, $data['pathUpdates']['allowedall']); @@ -257,7 +265,7 @@ public function test_it_can_build_acl_whitelist_for_existing_entities_allow_mult $changedEntity = $this->createChangedManageEntity(); $diff = $entity->diff($changedEntity); - $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', 'ACL'); + $data = $generator->generateForExistingEntity($entity, $diff, 'testaccepted', $this->getContact(), 'ACL'); $this->assertArrayHasKey('allowedall', $data['pathUpdates']); $this->assertSame(false, $data['pathUpdates']['allowedall']); @@ -334,4 +342,12 @@ private function createChangedManageEntity() $entity = m::mock($entity); return $entity; } + + private function getContact(): MockInterface&Contact + { + $mock = m::mock(Contact::class); + $mock->shouldReceive('getEmailAddress')->andReturn('j.doe@example.com'); + $mock->shouldReceive('getDisplayName')->andReturn('John Doe'); + return $mock; + } } diff --git a/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php b/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php index 5e2b24710..88e822b72 100644 --- a/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php @@ -20,6 +20,7 @@ use Mockery as m; use Mockery\Adapter\Phpunit\MockeryTestCase; +use Mockery\MockInterface; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator\ArpGenerator; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator\PrivacyQuestionsMetadataGenerator; use Surfnet\ServiceProviderDashboard\Application\Metadata\JsonGenerator\SpDashboardMetadataGenerator; @@ -125,7 +126,10 @@ public function test_it_can_build_oidcng_data_for_existing_entities() $diff = m::mock(EntityDiff::class); $diff->shouldReceive('getDiff') ->andReturn(['metaDataFields.name:en' => 'A new hope']); - $data = $generator->generateForExistingEntity($this->createManageEntity(), $diff, 'testaccepted'); + $data = $generator->generateForExistingEntity($this->createManageEntity(), $diff, 'testaccepted', $this->getContact()); + + $this->assertStringContainsString('Entity edited by user John Doe with email address "j.doe@example.com"', $data['pathUpdates']['revisionnote']); + unset($data['pathUpdates']['revisionnote']); $this->assertEquals( array( @@ -134,7 +138,6 @@ public function test_it_can_build_oidcng_data_for_existing_entities() 'entityid' => 'entityid', 'metaDataFields.name:en' => 'A new hope', 'state' => 'testaccepted', - 'revisionnote' => 'revisionnote', 'privacy' => 'privacy' ), 'type' => 'oauth20_rs', @@ -222,4 +225,12 @@ private function createChangedManageEntity() $entity = m::mock($entity); return $entity; } + + private function getContact(): MockInterface&Contact + { + $mock = m::mock(Contact::class); + $mock->shouldReceive('getEmailAddress')->andReturn('j.doe@example.com'); + $mock->shouldReceive('getDisplayName')->andReturn('John Doe'); + return $mock; + } }