Skip to content

Commit

Permalink
Fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 1, 2021
2 parents f5c5678 + a0655a6 commit 49e0e98
Show file tree
Hide file tree
Showing 57 changed files with 330 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,37 @@ class MetadataResolverControllerVersionEndpointsIntegrationTests extends Specifi
mrv2.body.name == 'resolverUPDATED'
}

def "SHIBUI-2182"() {
given:
def mr = new DynamicHttpMetadataResolver().with {
it.name = 'resolver2'
it.metadataRequestURLConstructionScheme = new RegexScheme().with {
it.match = 'This is the match field'
it.content = 'some content'
it
}
it
}
mr = repository.save(mr)
//Will create a second version for UPDATE revision
mr.name = 'resolverUPDATED'
mr.metadataRequestURLConstructionScheme.match = 'This is the match field too'
repository.save(mr)

when:
def allVersions = getAllMetadataResolverVersions(mr.resourceId, List)
def mrv1 = getMetadataResolverForVersion(mr.resourceId, allVersions.body[0].id, MetadataResolver)
def mrv2 = getMetadataResolverForVersion(mr.resourceId, allVersions.body[1].id, MetadataResolver)

then:
mrv1.statusCodeValue == 200
mrv1.body.name == 'resolver2'
mrv1.body.metadataRequestURLConstructionScheme.match == 'This is the match field'
mrv2.statusCodeValue == 200
mrv2.body.name == 'resolverUPDATED'
mrv2.body.metadataRequestURLConstructionScheme.match == 'This is the match field too'
}

def "SHIBUI-1386"() {
given:
MetadataResolver mr = new FileBackedHttpMetadataResolver(name: 'testme')
Expand Down Expand Up @@ -292,4 +323,4 @@ trait AttributeReleaseAndOverrides {
Map<String, Object> overrides(int filterIndex) {
(this.metadataFilters[filterIndex] as EntityAttributesFilter).relyingPartyOverrides
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}

void constructXmlNodeForFilter(EntityAttributesFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
markupBuilderDelegate.MetadataFilter('xsi:type': 'EntityAttributes') {
// TODO: enhance. currently this does weird things with namespaces
filter.attributes.each { attribute ->
Expand Down Expand Up @@ -128,6 +129,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {

// TODO: enhance
void constructXmlNodeForFilter(EntityRoleWhiteListFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
if (!filter.retainedRoles?.isEmpty()) {
markupBuilderDelegate.MetadataFilter(
'xsi:type': 'EntityRoleWhiteList',
Expand All @@ -142,6 +144,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}

void constructXmlNodeForFilter(NameIdFormatFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
def type = filter.nameIdFormatFilterTarget.nameIdFormatFilterTargetType
markupBuilderDelegate.MetadataFilter(
'xsi:type': 'NameIDFormat',
Expand Down Expand Up @@ -180,6 +183,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}

void constructXmlNodeForFilter(RequiredValidUntilFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
if (filter.xmlShouldBeGenerated()) {
markupBuilderDelegate.MetadataFilter(
'xsi:type': 'RequiredValidUntil',
Expand All @@ -189,6 +193,7 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}

void constructXmlNodeForFilter(SignatureValidationFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
if (filter.xmlShouldBeGenerated()) {
markupBuilderDelegate.MetadataFilter(id: filter.name,
'xsi:type': 'SignatureValidation',
Expand Down Expand Up @@ -459,8 +464,10 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}
}
mr.metadataFilters.each { edu.internet2.tier.shibboleth.admin.ui.domain.filters.MetadataFilter filter ->
doNamespaceProtectionFilter()
constructXmlNodeForFilter(filter, delegate)
if (filter.isFilterEnabled()) {
doNamespaceProtectionFilter()
constructXmlNodeForFilter(filter, delegate)
}
}
doNamespaceProtectionFilter()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ public String toString() {
String type;

String content;
}

@Transient
String match;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public MetadataResolver findSpecificVersionOfMetadataResolver(String resourceId,
return resolver;

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"properties": {
"name": {
"title": "label.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name",
"type": "string"
},
"@type": {
Expand Down Expand Up @@ -47,13 +47,10 @@
]
},
"match": {
"$id": "match",
"title": "label.match",
"description": "tooltip.match",
"type": "string",
"widget": {
"id": "string",
"required": true
}
"type": "string"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"properties": {
"name": {
"title": "label.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name",
"type": "string",
"widget": {
"id": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"properties": {
"name": {
"title": "label.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name",
"type": "string",
"widget": {
"id": "string",
Expand Down
10 changes: 8 additions & 2 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ action.groups=Groups
action.source-group=Group
action.enable=Enable
action.disable=Disable
action.get-latest=Get latest changes

action.add-new-role=Add new role
action.roles=Roles
action.source-role=Role
action.select-bundle=Select Bundle

action.get-latest=Get latest

value.enabled=Enabled
value.disabled=Disabled
value.current=Current
Expand Down Expand Up @@ -597,6 +600,7 @@ message.invalid-signing=Unless the response or the assertions are signed, SAML s

message.session-timeout-heading=Session timed out
message.session-timeout-body=Your session has timed out. Please login again.
message.session-timeout=An error has occurred while saving. Your session may have timed out.

tooltip.entity-id=Entity ID
tooltip.service-provider-name=Service Provider Name (Dashboard Display Only)
Expand Down Expand Up @@ -662,7 +666,7 @@ tooltip.max-cache-entry-size=The maximum response body size that may be cached,
tooltip.metadata-provider-name=Metadata Provider Name (for display on the Dashboard only)
tooltip.metadata-provider-type=Metadata Provider Type
tooltip.xml-id=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=The URL that the metadata is served from.
tooltip.metadata-file=The absolute path to the local metadata file to be loaded.
tooltip.init-from-backup=Flag indicating whether initialization should first attempt to load metadata from the backup file. If true, foreground initialization will be performed by loading the backing file, and then a refresh from the remote HTTP server will be scheduled to execute in a background thread, after a configured delay. This can improve IdP startup times when the remote HTTP file is large in size.
tooltip.backing-file=Specifies where the backing file is located. If the remote server is unavailable at startup, the backing file is loaded instead.
Expand Down Expand Up @@ -718,4 +722,6 @@ tooltip.group-name=Group Name
tooltip.group-description=Group Description

tooltip.role-name=Role Name
tooltip.role-description=Role Description
tooltip.role-description=Role Description

tooltip.contact-information=Contact Information
2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ tooltip.max-cache-entry-size=The maximum response body size that may be cached,
tooltip.metadata-provider-name=Metadata Provider Name (for display on the Dashboard only)
tooltip.metadata-provider-type=Metadata Provider Type
tooltip.xml-id=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=Identifier for logging, identification for command line reload, etc.
tooltip.metadata-url=The URL that the metadata is served from.
tooltip.metadata-file=The absolute path to the local metadata file to be loaded.
tooltip.init-from-backup=Flag indicating whether initialization should first attempt to load metadata from the backup file. If true, foreground initialization will be performed by loading the backing file, and then a refresh from the remote HTTP server will be scheduled to execute in a background thread, after a configured delay. This can improve IdP startup times when the remote HTTP file is large in size.
tooltip.backing-file=Specifies where the backing file is located. If the remote server is unavailable at startup, the backing file is loaded instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"properties": {
"name": {
"title": "label.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name-dashboard-display-only",
"description": "tooltip.metadata-provider-name",
"type": "string",
"widget": {
"id": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class IncommonJPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTes
def 'simple test generation of metadata-providers.xml'() {
when:
def mr = metadataResolverRepository.findAll().iterator().next()
mr.metadataFilters << new SignatureValidationFilter(requireSignedRoot: true, certificateFile: '%{idp.home}/credentials/inc-md-cert.pem')
mr.metadataFilters << new SignatureValidationFilter(enabled: true, requireSignedRoot: true, certificateFile: '%{idp.home}/credentials/inc-md-cert.pem')
mr.metadataFilters << requiredValidUntilFilterForXmlGenerationTests()
mr.metadataFilters << entityRoleWhiteListFilterForXmlGenerationTests()
metadataResolverRepository.save(mr)
Expand All @@ -52,9 +52,10 @@ class IncommonJPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTes
when:
//TODO: this might break later
def mr = metadataResolverRepository.findAll().iterator().next()
mr.metadataFilters << new SignatureValidationFilter(requireSignedRoot: true, certificateFile: '%{idp.home}/credentials/inc-md-cert.pem')
mr.metadataFilters << new SignatureValidationFilter(enabled: true, requireSignedRoot: true, certificateFile: '%{idp.home}/credentials/inc-md-cert.pem')
mr.metadataFilters << requiredValidUntilFilterForXmlGenerationTests()
mr.metadataFilters.add(new EntityAttributesFilter().with {
it.enabled = true
it.entityAttributesFilterTarget = new EntityAttributesFilterTarget().with {
it.entityAttributesFilterTargetType = EntityAttributesFilterTarget.EntityAttributesFilterTargetType.ENTITY
it.value = ['https://sp1.example.org']
Expand All @@ -81,13 +82,15 @@ class IncommonJPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTes
EntityRoleWhiteListFilter entityRoleWhiteListFilterForXmlGenerationTests() {
new EntityRoleWhiteListFilter().with {
it.retainedRoles = ['md:SPSSODescriptor']
it.enabled = true
it
}
}

RequiredValidUntilFilter requiredValidUntilFilterForXmlGenerationTests() {
new RequiredValidUntilFilter().with {
it.maxValidityInterval = 'P14D'
it.enabled = true
it
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ class JPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTest {
generatedXmlIsTheSameAsExpectedXml('/conf/661.xml', domBuilder.parseText(writer.toString()))
}

def 'test generating xml when filter is disabled'() {
given:
def filter = testObjectGenerator.entityAttributesFilterWithConditionScript()
filter.setEnabled(Boolean.FALSE)

when:
genXmlSnippet(markupBuilder) {
JPAMetadataResolverServiceImpl.cast(metadataResolverService).constructXmlNodeForFilter(filter, it)
}

then:
generatedXmlIsTheSameAsExpectedXml('/conf/661.3.xml', domBuilder.parseText(writer.toString()))
}

def 'test generating EntityAttributesFilter xml snippet with regex'() {
given:
def filter = testObjectGenerator.entityAttributesFilterWithRegex()
Expand Down Expand Up @@ -177,6 +191,7 @@ class JPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTest {
def 'test generating RequiredValidUntilFilter xml snippet'() {
given:
def filter = new RequiredValidUntilFilter().with {
it.enabled = true
it.maxValidityInterval = 'P14D'
it
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class TestObjectGenerator {
it.dynamicTrustedNamesStrategyRef = generator.randomString(10)
it.trustEngineRef = generator.randomString(10)
it.publicKey = generator.randomString(50)
it.enabled = true;
it
}
}
Expand All @@ -202,6 +203,7 @@ class TestObjectGenerator {
it.name = 'EntityRoleWhiteList'
it.retainedRoles = ['role1', 'role2']
it.removeRolelessEntityDescriptors = true
it.enabled = true;
it
}
}
Expand All @@ -212,6 +214,7 @@ class TestObjectGenerator {
it.setEntityAttributesFilterTarget(buildEntityAttributesFilterTarget())
it.setAttributes(buildAttributesList())
it.intoTransientRepresentation()
it.enabled = true;
it
}
}
Expand All @@ -221,6 +224,7 @@ class TestObjectGenerator {
it.name = 'EntityAttributes'
it.setEntityAttributesFilterTarget(buildEntityAttributesFilterTargetWithConditionScript())
it.intoTransientRepresentation()
it.enabled = true;
it
}
}
Expand All @@ -230,13 +234,15 @@ class TestObjectGenerator {
it.name = 'EntityAttributes'
it.setEntityAttributesFilterTarget(buildEntityAttributesFilterTargetWithRegex())
it.intoTransientRepresentation()
it.enabled = true;
it
}
}

RequiredValidUntilFilter requiredValidUntilFilter() {
return new RequiredValidUntilFilter().with {
it.maxValidityInterval = 'P14D'
it.enabled = true;
it
}
}
Expand All @@ -246,6 +252,7 @@ class TestObjectGenerator {
it.name = "NameIDFormat"
it.formats = ['urn:oasis:names:tc:SAML:2.0:nameid-format:persistent']
it.setNameIdFormatFilterTarget(new NameIdFormatFilterTarget(nameIdFormatFilterTargetType: ENTITY, singleValue: 'https://sp1.example.org'))
it.enabled = true;
it
}
}
Expand All @@ -255,6 +262,7 @@ class TestObjectGenerator {
it.name = requiredValidUntilFilter.name
it.resourceId = requiredValidUntilFilter.resourceId
it.maxValidityInterval = requiredValidUntilFilter.maxValidityInterval
it.enabled = true;
it
}
}
Expand All @@ -270,6 +278,7 @@ class TestObjectGenerator {
it.requireSignedRoot = signatureValidationFilter.requireSignedRoot
it.certificateFile = signatureValidationFilter.certificateFile
it.defaultCriteriaRef = signatureValidationFilter.defaultCriteriaRef
it.enabled = true;
it
}
}
Expand Down
2 changes: 2 additions & 0 deletions backend/src/test/resources/conf/661.3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<MetadataProvider id='ShibbolethMetadata' xmlns='urn:mace:shibboleth:2.0:metadata' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ChainingMetadataProvider' xsi:schemaLocation='urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd urn:mace:shibboleth:2.0:resource http://shibboleth.net/schema/idp/shibboleth-resource.xsd urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd'>
</MetadataProvider>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=shibui
group=edu.internet2.tier.shibboleth.admin.ui
version=1.10.0-SNAPSHOT
version=1.11.0-SNAPSHOT

shibboleth.version=3.4.4
opensaml.version=3.4.3
Expand Down
Loading

0 comments on commit 49e0e98

Please sign in to comment.