-
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.
- Loading branch information
Showing
8 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/EmailAddress.java
This file contains hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/GivenName.java
This file contains hidden or 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
65 changes: 65 additions & 0 deletions
65
...2/tier/shibboleth/admin/ui/repository/envers/EntityDescriptorEnversVersioningTests.groovy
This file contains hidden or 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,65 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.repository.envers | ||
|
|
||
| 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.configuration.TestConfiguration | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor | ||
| import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository | ||
| import org.hibernate.envers.AuditReaderFactory | ||
| import org.hibernate.envers.query.AuditQuery | ||
| import org.springframework.beans.factory.annotation.Autowired | ||
| import org.springframework.boot.autoconfigure.domain.EntityScan | ||
| import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest | ||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories | ||
| import org.springframework.test.context.ContextConfiguration | ||
| import org.springframework.transaction.PlatformTransactionManager | ||
| import spock.lang.Specification | ||
|
|
||
| import javax.persistence.EntityManager | ||
|
|
||
| import static edu.internet2.tier.shibboleth.admin.ui.domain.util.entitydescriptors.EntityDescriptors.prebakedEntityDescriptor | ||
| import static edu.internet2.tier.shibboleth.admin.ui.repository.envers.EnversTestsSupport.doInExplicitTransaction | ||
|
|
||
| /** | ||
| * Testing entity descriptor envers versioning | ||
| */ | ||
| @DataJpaTest | ||
| @ContextConfiguration(classes = [CoreShibUiConfiguration, InternationalizationConfiguration, TestConfiguration, SearchConfiguration]) | ||
| @EnableJpaRepositories(basePackages = ["edu.internet2.tier.shibboleth.admin.ui"]) | ||
| @EntityScan("edu.internet2.tier.shibboleth.admin.ui") | ||
| class EntityDescriptorEnversVersioningTests extends Specification { | ||
|
|
||
| @Autowired | ||
| EntityDescriptorRepository entityDescriptorRepository | ||
|
|
||
| @Autowired | ||
| EntityManager entityManager | ||
|
|
||
| @Autowired | ||
| PlatformTransactionManager txMgr | ||
|
|
||
| @Autowired | ||
| OpenSamlObjects openSamlObjects | ||
|
|
||
| def "test versioning with contact persons"() { | ||
| when: | ||
| EntityDescriptor ed = doInExplicitTransaction(txMgr) { | ||
| entityDescriptorRepository.save(prebakedEntityDescriptor(openSamlObjects)) | ||
| } | ||
| def entityDescriptorHistory = resolverHistory() | ||
|
|
||
| then: | ||
| entityDescriptorHistory.size() == 1 | ||
| } | ||
|
|
||
| private resolverHistory() { | ||
| def auditReader = AuditReaderFactory.get(entityManager) | ||
| AuditQuery auditQuery = auditReader | ||
| .createQuery() | ||
| .forRevisionsOfEntity(EntityDescriptor, false, false) | ||
| auditQuery.resultList | ||
|
|
||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
...groovy/edu/internet2/tier/shibboleth/admin/ui/repository/envers/EnversTestsSupport.groovy
This file contains hidden or 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,20 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.repository.envers | ||
|
|
||
| import org.springframework.transaction.PlatformTransactionManager | ||
| import org.springframework.transaction.support.DefaultTransactionDefinition | ||
|
|
||
| import static org.springframework.transaction.TransactionDefinition.PROPAGATION_REQUIRES_NEW | ||
|
|
||
| class EnversTestsSupport { | ||
|
|
||
| //This explicit low level transaction dance is required in order to verify history/version data that envers | ||
| //writes out only after the explicit transaction is committed, therefore making it impossible to verify within the main tx | ||
| //boundary of the test method which commits tx only after an execution of the test method. This let's us explicitly | ||
| //start/commit transaction making envers data written out and verifiable | ||
| static doInExplicitTransaction(PlatformTransactionManager txMgr, Closure uow) { | ||
| def txStatus = txMgr.getTransaction(new DefaultTransactionDefinition(PROPAGATION_REQUIRES_NEW)) | ||
| def entity = uow() | ||
| txMgr.commit(txStatus) | ||
| entity | ||
| } | ||
| } |