Skip to content

Commit

Permalink
[SHIBUI-723]
Browse files Browse the repository at this point in the history
Updated spring-extensions dep to be available at compile time.
Updated OpenSamlMetadataResolverConstructorHelper to return a default
value when a null is detected.
Updated MetadataResolverConverterServiceImpl to use a ClassPathResource
and convert it as necessary.
Updated tests to remove /tmp/foo.txt file generation.
Updated TestObjectGenerator to build empty attributes objects inside
resolvers.
  • Loading branch information
Bill Smith committed Aug 22, 2018
1 parent 1179a46 commit 402c3a8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ dependencies {
testCompile "org.xmlunit:xmlunit-core:2.5.1"
testRuntime 'cglib:cglib-nodep:3.2.5'

testCompile "net.shibboleth.ext:spring-extensions:5.4.0-SNAPSHOT"
compile "net.shibboleth.ext:spring-extensions:5.4.0-SNAPSHOT"

//JSON schema generator
testCompile 'com.kjetland:mbknor-jackson-jsonschema_2.12:1.0.29'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public static void updateOpenSamlMetadataResolverFromReloadableMetadataResolverA
reloadingMetadataResolver.setExpirationWarningThreshold(toMillis(attributes.getExpirationWarningThreshold()));
reloadingMetadataResolver.setMaxRefreshDelay(toMillis(attributes.getMaxRefreshDelay()));
reloadingMetadataResolver.setMinRefreshDelay(toMillis(attributes.getMinRefreshDelay()));
reloadingMetadataResolver.setRefreshDelayFactor(attributes.getRefreshDelayFactor().floatValue());

//TODO: I think we may need to take another look at setting the defaults properly on our attributes.
reloadingMetadataResolver.setRefreshDelayFactor(attributes.getRefreshDelayFactor() == null ? 0.75f : attributes.getRefreshDelayFactor().floatValue());

//TODO: What should we do here if this data is null/empty?
reloadingMetadataResolver.setResolveViaPredicatesOnly(attributes.getResolveViaPredicatesOnly() == null ? false : attributes.getResolveViaPredicatesOnly());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.opensaml.OpenSamlFunctionDrivenDynamicHTTPMetadataResolver;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.opensaml.OpenSamlLocalDynamicMetadataResolver;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.opensaml.OpenSamlResourceBackedMetadataResolver;
import net.shibboleth.ext.spring.resource.ResourceHelper;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
import net.shibboleth.utilities.java.support.resource.Resource;
import org.apache.lucene.index.IndexWriter;
Expand Down Expand Up @@ -78,8 +79,7 @@ private OpenSamlResourceBackedMetadataResolver convertToOpenSamlRepresentation(R
//TODO: What sort of resource type should be created here? URL?
break;
case CLASSPATH:
//TODO: Not sure what kind of resource class to use here.
// resource = (Resource) new ClassPathResource(resolver.getClasspathMetadataResource().getFile()); // this doesn't work.
resource = ResourceHelper.of(new ClassPathResource(resolver.getClasspathMetadataResource().getFile()));
break;
default:
throw new RuntimeException("Unsupported resource type!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ class MetadataResolversControllerIntegrationTests extends Specification {
result.statusCodeValue == 201
result.headers.Location[0].contains(BASE_URI)

cleanup:
def file = new File('/tmp/foo.txt')
file.delete()

where:
resolverType | _
'DynamicHttp' | _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ class TestObjectGenerator {
new DynamicHttpMetadataResolver().with {
it.name = 'DynamicHTTP'
it.xmlId = 'DynamicHTTP'
it.dynamicMetadataResolverAttributes = new DynamicMetadataResolverAttributes().with {
it
}
it
}
}
Expand All @@ -445,6 +448,10 @@ class TestObjectGenerator {
new LocalDynamicMetadataResolver().with {
it.name = 'LocalDynamic'
it.xmlId = 'LocalDynamic'
it.sourceDirectory = '/tmp'
it.dynamicMetadataResolverAttributes = new DynamicMetadataResolverAttributes().with {
it
}
it
}
}
Expand All @@ -459,18 +466,22 @@ class TestObjectGenerator {
it.workingCopyDirectory = '%{idp.home}/metadata/svn'
it
}
it.reloadableMetadataResolverAttributes = new ReloadableMetadataResolverAttributes().with {
it
}
it
}
}

ResourceBackedMetadataResolver resourceBackedMetadataResolverForClasspath() {
def file = new File('/tmp/foo.txt') // should we really do this?
file.write 'This is a temp file for a groovy test.'
new ResourceBackedMetadataResolver().with {
it.name = 'ClasspathResourceMetadata'
it.xmlId = 'ClasspathResourceMetadata'
it.classpathMetadataResource = new ClasspathMetadataResource().with {
it.file = '/tmp/foo.txt'
it.file = 'metadata/metadata.xml'
it
}
it.reloadableMetadataResolverAttributes = new ReloadableMetadataResolverAttributes().with {
it
}
it
Expand Down

0 comments on commit 402c3a8

Please sign in to comment.