-
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.
Fixes related to Attribute hashCode not being equal.
- Loading branch information
Bill Smith
committed
Jun 4, 2018
1 parent
4b03b1b
commit 0ffb855
Showing
5 changed files
with
80 additions
and
1 deletion.
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
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
74 changes: 74 additions & 0 deletions
74
...est/groovy/edu/internet2/tier/shibboleth/admin/ui/repository/FilterRepositoryTests.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,74 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.repository | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import edu.internet2.tier.shibboleth.admin.ui.configuration.CoreShibUiConfiguration | ||
import edu.internet2.tier.shibboleth.admin.ui.configuration.MetadataResolverConfiguration | ||
import edu.internet2.tier.shibboleth.admin.ui.configuration.SearchConfiguration | ||
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.EntityAttributesFilter | ||
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.annotation.DirtiesContext | ||
import org.springframework.test.context.ContextConfiguration | ||
import spock.lang.Specification | ||
|
||
import javax.persistence.EntityManager | ||
|
||
@DataJpaTest | ||
@ContextConfiguration(classes=[CoreShibUiConfiguration, SearchConfiguration, MetadataResolverConfiguration]) | ||
@EnableJpaRepositories(basePackages = ["edu.internet2.tier.shibboleth.admin.ui"]) | ||
@EntityScan("edu.internet2.tier.shibboleth.admin.ui") | ||
@DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD) | ||
class FilterRepositoryTests extends Specification { | ||
|
||
@Autowired | ||
FilterRepository repositoryUnderTest | ||
|
||
@Autowired | ||
EntityManager entityManager | ||
|
||
def "EntityAttributesFilter hashcode works as desired"() { | ||
given: | ||
def entityAttributesFilterJson = '''{ | ||
"name": "EntityAttributes", | ||
"resourceId": "29a5d409-562a-41cd-acee-e9b3d7098d05", | ||
"filterEnabled": false, | ||
"entityAttributesFilterTarget": { | ||
"entityAttributesFilterTargetType": "CONDITION_SCRIPT", | ||
"value": [ | ||
"TwUuSOz5O6" | ||
] | ||
}, | ||
"attributeRelease": [ | ||
"WbkhLQNI3m" | ||
], | ||
"relyingPartyOverrides": { | ||
"signAssertion": true, | ||
"dontSignResponse": true, | ||
"turnOffEncryption": true, | ||
"useSha": true, | ||
"ignoreAuthenticationMethod": false, | ||
"omitNotBefore": true, | ||
"responderId": null, | ||
"nameIdFormats": [ | ||
"xLenUFmCLn" | ||
], | ||
"authenticationMethods": [] | ||
}, | ||
"@type": "EntityAttributes" | ||
}''' | ||
|
||
when: | ||
def filter = new ObjectMapper().readValue(entityAttributesFilterJson.bytes, EntityAttributesFilter) | ||
def persistedFilter = repositoryUnderTest.save(filter) | ||
entityManager.flush() | ||
|
||
then: | ||
def item1 = repositoryUnderTest.findByResourceId(persistedFilter.resourceId) | ||
entityManager.clear() | ||
def item2 = repositoryUnderTest.findByResourceId(persistedFilter.resourceId) | ||
|
||
item1.hashCode() == item2.hashCode() | ||
} | ||
} |