-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding testing to validate callback to the configuration is updated properly when the definitions are changed
- Loading branch information
Showing
6 changed files
with
163 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...internet2/tier/shibboleth/admin/ui/service/ICustomEntityAttributesDefinitionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
|
||
| public interface ICustomEntityAttributesDefinitionListener { | ||
| void customEntityAttributesDefinitionChangeOccurred(); | ||
| } |
93 changes: 93 additions & 0 deletions
93
...nternet2/tier/shibboleth/admin/ui/configuration/CustomPropertiesConfigurationTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.configuration | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.configuration.CoreShibUiConfiguration | ||
| import edu.internet2.tier.shibboleth.admin.ui.configuration.InternationalizationConfiguration | ||
| import edu.internet2.tier.shibboleth.admin.ui.configuration.SearchConfiguration | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.CustomEntityAttributeDefinition | ||
| import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.CustomEntityAttributeDefinitionRepository | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.CustomEntityAttributeFilterValueRepository | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.repository.RoleRepository | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository | ||
| import edu.internet2.tier.shibboleth.admin.ui.service.CustomEntityAttributesDefinitionService | ||
| import edu.internet2.tier.shibboleth.admin.ui.service.CustomEntityAttributesDefinitionServiceImpl | ||
|
|
||
| import javax.persistence.EntityManager | ||
|
|
||
| import org.opensaml.saml.metadata.resolver.MetadataResolver | ||
| import org.springframework.beans.factory.annotation.Autowired | ||
| import org.springframework.beans.factory.annotation.Qualifier | ||
| import org.springframework.boot.autoconfigure.domain.EntityScan | ||
| import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest | ||
| import org.springframework.boot.test.context.SpringBootTest | ||
| import org.springframework.boot.test.context.TestConfiguration | ||
| import org.springframework.context.annotation.Bean | ||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories | ||
| import org.springframework.security.core.userdetails.UsernameNotFoundException | ||
| import org.springframework.test.context.ActiveProfiles | ||
| import org.springframework.test.context.ContextConfiguration | ||
|
|
||
| import spock.lang.Specification | ||
|
|
||
| /** | ||
| * Tests for <code>edu.internet2.tier.shibboleth.admin.ui.configuration.CustomPropertiesConfiguration</code> | ||
| */ | ||
| @DataJpaTest | ||
| @ContextConfiguration(classes=[CoreShibUiConfiguration, InternationalizationConfiguration, SearchConfiguration, edu.internet2.tier.shibboleth.admin.ui.configuration.TestConfiguration]) | ||
| @EnableJpaRepositories(basePackages = ["edu.internet2.tier.shibboleth.admin.ui"]) | ||
| @EntityScan("edu.internet2.tier.shibboleth.admin.ui") | ||
| class CustomPropertiesConfigurationTests extends Specification { | ||
|
|
||
| @Autowired | ||
| @Qualifier(value="customPropertiesConfiguration") | ||
| CustomPropertiesConfiguration configUnderTest | ||
|
|
||
| @Autowired | ||
| CustomEntityAttributesDefinitionService ceadService | ||
|
|
||
| @Autowired | ||
| CustomEntityAttributeDefinitionRepository repository; | ||
|
|
||
| @Autowired | ||
| EntityManager entityManager | ||
|
|
||
| def "Updating Custom Entity Attribute Definitions will update the CustomPropertiesConfiguration automatically"() { | ||
| given: 'Test defaults loaded (ie no CEADs in DB)' | ||
|
|
||
| expect: | ||
| ceadService.getAllDefinitions().size() == 0 | ||
| configUnderTest.getOverrides().size() == 10 | ||
|
|
||
| def ca = new CustomEntityAttributeDefinition().with { | ||
| it.name = "newDefName" | ||
| it.attributeType = "STRING" | ||
| it.defaultValue = "foobar" | ||
| it | ||
| } | ||
|
|
||
| ceadService.createOrUpdateDefinition(ca) | ||
| entityManager.flush() | ||
|
|
||
| ceadService.getAllDefinitions().size() == 1 | ||
| configUnderTest.getOverrides().size() == 11 | ||
|
|
||
| def ca2 = new CustomEntityAttributeDefinition().with { | ||
| it.name = "newDefName2" | ||
| it.attributeType = "STRING" | ||
| it.defaultValue = "foobar2" | ||
| it | ||
| } | ||
|
|
||
| ceadService.createOrUpdateDefinition(ca2) | ||
| entityManager.flush() | ||
|
|
||
| ceadService.getAllDefinitions().size() == 2 | ||
| configUnderTest.getOverrides().size() == 12 | ||
|
|
||
| ceadService.deleteDefinition(ca) | ||
| entityManager.flush() | ||
|
|
||
| ceadService.getAllDefinitions().size() == 1 | ||
| configUnderTest.getOverrides().size() == 11 | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters