Skip to content

Commit

Permalink
Merge branch 'master' of bitbucket.org:unicon/shib-idp-ui into bugfix…
Browse files Browse the repository at this point in the history
…/refresh-delay-factor
  • Loading branch information
rmathis committed Feb 26, 2019
2 parents 483adc5 + d39fa70 commit b630578
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope
}
if (overrideProperty.getPersistType() != null &&
!overrideProperty.getPersistType().equals(overrideProperty.getDisplayType())) {
attributeValues = getValueFromXMLObject(jpaAttribute.getAttributeValues().get(0));
attributeValues = overrideProperty.getPersistValue().equals(getValueFromXMLObject(jpaAttribute.getAttributeValues().get(0)));
} else {
attributeValues = Boolean.valueOf(((XSBoolean) jpaAttribute.getAttributeValues()
.get(0)).getStoredValue());
Expand All @@ -669,6 +669,9 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope
}
}

// TODO: fix this; there is a problem with the way that defaults are working and the processing from the front end
ModelRepresentationConversions.completeMe(relyingPartyOverrides);

representation.setRelyingPartyOverrides(relyingPartyOverrides);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ public static Map<String, Object> getRelyingPartyOverridesRepresentationFromAttr
return relyingPartyOverrides;
}

// TODO: fix this; currently there is a problem with not returning a value
public static Map<String,Object> completeMe(Map<String, Object> relyingPartyOverrides) {
customPropertiesConfiguration
.getOverrides()
.stream()
.filter(o -> !relyingPartyOverrides.containsKey(o.getName()))
.filter(o -> o.getDisplayType().equals("boolean"))
.forEach(p -> relyingPartyOverrides.put(p.getName(), getDefaultValueFromProperty(p)));
return relyingPartyOverrides;
}

private static Object getDefaultValueFromProperty(RelyingPartyOverrideProperty property) {
switch (property.getDisplayType()) {
case "boolean":
return Boolean.getBoolean(property.getDefaultValue());
}
return null;
}

public static Object getOverrideFromAttribute(Attribute attribute) {
RelyingPartyOverrideProperty relyingPartyOverrideProperty = customPropertiesConfiguration.getOverrides().stream()
.filter(it -> it.getAttributeFriendlyName().equals(attribute.getFriendlyName())).findFirst().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.web.servlet.setup.MockMvcBuilders
import org.springframework.web.client.RestTemplate
import spock.lang.Ignore
import spock.lang.Specification
import spock.lang.Subject

Expand Down Expand Up @@ -696,6 +697,7 @@ class EntityDescriptorControllerTests extends Specification {
result.andExpect(status().is(403))
}
@Ignore("until we handle the workaround for SHIBUI-1237")
def "POST /EntityDescriptor handles XML happily"() {
given:
def username = 'admin'
Expand Down Expand Up @@ -816,6 +818,7 @@ class EntityDescriptorControllerTests extends Specification {
.andExpect(content().string("{\"errorCode\":\"409\",\"errorMessage\":\"The entity descriptor with entity id [http://test.scaldingspoon.org/test1] already exists.\"}"))
}
@Ignore("until we handle the workaround for SHIBUI-1237")
def "POST /EntityDescriptor handles x-www-form-urlencoded happily"() {
given:
def username = 'admin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import edu.internet2.tier.shibboleth.admin.ui.ShibbolethUiApplication
import edu.internet2.tier.shibboleth.admin.ui.configuration.CoreShibUiConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomPropertiesConfiguration
import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor
import edu.internet2.tier.shibboleth.admin.ui.domain.SPSSODescriptor
import edu.internet2.tier.shibboleth.admin.ui.domain.XSAny
import edu.internet2.tier.shibboleth.admin.ui.domain.XSAnyBuilder
import edu.internet2.tier.shibboleth.admin.ui.domain.XSBoolean
Expand Down Expand Up @@ -54,7 +55,7 @@ class JPAEntityDescriptorServiceImplTests extends Specification {
it
}

def service
JPAEntityDescriptorServiceImpl service

JacksonTester<EntityDescriptorRepresentation> jacksonTester

Expand Down Expand Up @@ -857,6 +858,28 @@ class JPAEntityDescriptorServiceImplTests extends Specification {
thrown RuntimeException
}

def "SHIBUI-1237"() {
given:
// this is very inefficient, but it might work
def inputRepresentation = new EntityDescriptorRepresentation().with {
it.id = 'test'
it.entityId = 'test'
it.relyingPartyOverrides = [
'useSha': true,
'ignoreAuthenticationMethod': true
]
it
}

when:
def entityDescriptor = service.createDescriptorFromRepresentation(inputRepresentation)
def representation = service.createRepresentationFromDescriptor(entityDescriptor)

then:
assert representation.relyingPartyOverrides.get('useSha') instanceof Boolean
assert representation.relyingPartyOverrides.get('ignoreAuthenticationMethod') instanceof Boolean
}

EntityDescriptor generateRandomEntityDescriptor() {
EntityDescriptor ed = new EntityDescriptor()

Expand Down

0 comments on commit b630578

Please sign in to comment.