Skip to content

Commit

Permalink
Merge branch 'bugfix/SHIBUI-1414' of bitbucket.org:unicon/shib-idp-ui…
Browse files Browse the repository at this point in the history
… into feature/SHIBUI-1382
  • Loading branch information
rmathis committed Aug 20, 2019
2 parents 5b2f6cc + 643b12b commit bce2509
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package edu.internet2.tier.shibboleth.admin.ui.controller

import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor
import edu.internet2.tier.shibboleth.admin.ui.domain.Organization
import edu.internet2.tier.shibboleth.admin.ui.domain.OrganizationDisplayName
import edu.internet2.tier.shibboleth.admin.ui.domain.OrganizationName
import edu.internet2.tier.shibboleth.admin.ui.domain.OrganizationURL
import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityDescriptorRepresentation
import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
import org.springframework.http.MediaType
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

Expand Down Expand Up @@ -100,6 +111,46 @@ class EntityDescriptorControllerVersionEndpointsIntegrationTests extends Specifi
edv2.body.serviceProviderName == 'SP2'
}

@DirtiesContext(methodMode = DirtiesContext.MethodMode.AFTER_METHOD)
def 'SHIBUI-1414'() {
given:
def ed = new EntityDescriptor(entityID: 'testme', serviceProviderName: 'testme').with {
entityDescriptorRepository.save(it)
}.with {
it.setOrganization(new Organization().with {
it.organizationNames = [new OrganizationName(value: 'testme', XMLLang: 'en')]
it.organizationDisplayNames = [new OrganizationDisplayName(value: 'testme', XMLLang: 'en')]
it.organizationURLs = [new OrganizationURL(value: 'http://testme.org', XMLLang: 'en')]
it
})
entityDescriptorRepository.save(it)
}

when:
def headers = new HttpHeaders().with {
it.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
it
}

def allVersions = getAllEntityDescriptorVersions(ed.resourceId, List)
def edv1 = getEntityDescriptorForVersion(ed.resourceId, allVersions.body[0].id, String).body
def tedv2 = getEntityDescriptorForVersion(ed.resourceId, allVersions.body[1].id, EntityDescriptorRepresentation).body

def aedv1 = new JsonSlurper().parseText(edv1).with {
it.put('version', tedv2.version)
it
}.with {
JsonOutput.toJson(it)
}

def request = new HttpEntity(aedv1, headers)
def response = this.restTemplate.exchange("/api/EntityDescriptor/${ed.resourceId}", HttpMethod.PUT, request, String)

then:
response.statusCodeValue != 400
noExceptionThrown()
}

private getAllEntityDescriptorVersions(String resourceId, responseType) {
this.restTemplate.getForEntity(resourceUriFor(ALL_VERSIONS_URI, resourceId), responseType)
}
Expand Down
18 changes: 9 additions & 9 deletions backend/src/main/resources/metadata-sources-ui-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"default": false
},
"organization": {
"type": ["object", "null"],
"type": "object",
"properties": {
"name": {
"title": "label.organization-name",
Expand Down Expand Up @@ -68,13 +68,13 @@
"contacts": {
"title": "label.contact-information",
"description": "tooltip.contact-information",
"type": ["array", "null"],
"type": "array",
"items": {
"$ref": "#/definitions/Contact"
}
},
"mdui": {
"type": ["object", "null"],
"type": "object",
"widget": {
"id": "fieldset"
},
Expand Down Expand Up @@ -143,7 +143,7 @@
}
},
"securityInfo": {
"type": ["object", "null"],
"type": "object",
"widget": {
"id": "fieldset"
},
Expand Down Expand Up @@ -245,13 +245,13 @@
"assertionConsumerServices": {
"title": "label.assertion-consumer-service-endpoints",
"description": "",
"type": ["array", "null"],
"type": "array",
"items": {
"$ref": "#/definitions/AssertionConsumerService"
}
},
"serviceProviderSsoDescriptor": {
"type": ["object", "null"],
"type": "object",
"widget": {
"id": "fieldset"
},
Expand Down Expand Up @@ -299,17 +299,17 @@
"logoutEndpoints": {
"title": "label.logout-endpoints",
"description": "tooltip.logout-endpoints",
"type": ["array", "null"],
"type": "array",
"items": {
"$ref": "#/definitions/LogoutEndpoint"
}
},
"relyingPartyOverrides": {
"type": ["object", "null"],
"type": "object",
"properties": {}
},
"attributeRelease": {
"type": ["array", "null"],
"type": "array",
"title": "label.attribute-release",
"description": "Attribute release table - select the attributes you want to release (default unchecked)",
"widget": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.TestConfiguration
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Profile
import org.springframework.core.io.ResourceLoader
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification
Expand All @@ -23,7 +24,7 @@ import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResour
* @author Dmitriy Kopylenko
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("no-auth")
@ActiveProfiles(["no-auth", "badjson"])
class BadJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Specification {

@Autowired
Expand All @@ -42,6 +43,7 @@ class BadJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Speci
}

@TestConfiguration
@Profile('badjson')
static class Config {
@Bean
JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(ResourceLoader resourceLoader,
Expand Down

0 comments on commit bce2509

Please sign in to comment.