[java-idp-plugin-duo] branch master updated: JDUO-7 Add service API tests
Phil Smart
philip.smart at jisc.ac.uk
Fri Jul 24 10:45:03 UTC 2020
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch master
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=5eee2725a22611df50f009ee4592079d91ec0e62
The following commit(s) were added to refs/heads/master by this push:
new 5eee272 JDUO-7 Add service API tests
5eee272 is described below
commit 5eee2725a22611df50f009ee4592079d91ec0e62
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Jul 24 11:45:01 2020 +0100
JDUO-7 Add service API tests
Basic tests to check plugin setup and init.
https://issues.shibboleth.net/jira/browse/JDUO-7
---
.../idp/plugin/authn/duo/DuoOIDCDescription.java | 12 +++++---
.../idp/plugin/authn/duo/PluginTest.java | 35 ++++++++++++++--------
2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
index 683dc6b..6bcdb2f 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
@@ -24,6 +24,8 @@ import java.util.List;
import javax.annotation.Nonnull;
+import org.springframework.core.io.ClassPathResource;
+
import net.shibboleth.idp.plugin.AbstractPluginDescription;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
@@ -42,6 +44,12 @@ public class DuoOIDCDescription extends AbstractPluginDescription{
@Nonnull @NonnullElements public List<String> getAdditionalPropertyFiles(){
return List.of("/conf/authn/idp-duo-oidc.properties");
}
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull @NonnullElements public List<URL> getUpdateURLs() throws IOException {
+ return Collections.singletonList(new ClassPathResource("META-INF/plugins/plugin.props").getURL());
+ }
@Override
@@ -59,9 +67,5 @@ public class DuoOIDCDescription extends AbstractPluginDescription{
return 1;
}
- @Override
- @Nonnull @NonnullElements public List<URL> getUpdateURLs() throws IOException {
- return Collections.emptyList();
- }
}
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
index bde7313..90ea0e3 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
@@ -20,41 +20,52 @@ package net.shibboleth.idp.plugin.authn.duo;
import org.testng.annotations.Test;
import net.shibboleth.idp.plugin.PluginDescription;
+import net.shibboleth.idp.plugin.PluginSupport.SupportLevel;
+import net.shibboleth.idp.plugin.PluginVersion;
import net.shibboleth.idp.plugin.impl.PluginState;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
import java.util.ServiceLoader;
import org.testng.annotations.BeforeClass;
-/** Test the plugin descrition. */
+/** Test the plugin description. If nothing else, it ensures the plugin has the correct basic setup. */
public class PluginTest {
/** The plugin to test.*/
- private PluginDescription duoPlugin;
+ private PluginDescription duo;
- @BeforeClass
- public void beforeMethod() {
+ /**
+ * Find the plugin.
+ */
+ @BeforeClass public void beforeMethod() {
final ServiceLoader<PluginDescription> loader = ServiceLoader.load(PluginDescription.class);
- System.out.println(loader.toString());
for (final PluginDescription service : loader) {
- if (getClass().getPackageName().contentEquals(service.getPluginId())) {
- duoPlugin = service;
+ if ("net.shibboleth.idp.plugin.authn.duo".contentEquals(service.getPluginId())) {
+ duo = service;
break;
}
}
- assertNotNull(duoPlugin);
+ assertNotNull(duo);
}
- @Test
- public void testState() throws ComponentInitializationException {
- final PluginState state = new PluginState(duoPlugin);
- //state.initialize();
+ /** Test the plugin state.*/
+ @Test public void testState() throws ComponentInitializationException {
+ final PluginState state = new PluginState(duo);
+ state.initialize();
+ assertTrue(state.getAvailableVersions().contains(
+ new PluginVersion(duo.getMajorVersion(),duo.getMinorVersion(), duo.getPatchVersion())));
+ assertEquals(state.getSupportLevel(), SupportLevel.Current);
+ assertTrue(state.isSupportedWithIdPVersion("4.1.0"));
+ assertFalse(state.isSupportedWithIdPVersion("5.0.0"));
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list