Skip to content

Commit

Permalink
Rename from DuoPlugin to DuoUniversalPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronAtDuo committed Aug 25, 2021
1 parent e9b42aa commit e96cb3c
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/DuoPlugin.jar
asset_name: DuoPlugin.jar
asset_path: target/DuoUniversalPlugin.jar
asset_name: DuoUniversalPlugin.jar
asset_content_type: application/java-archive
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<finalName>DuoPlugin</finalName>
<finalName>DuoUniversalPlugin</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
Expand Down
2 changes: 1 addition & 1 deletion src/main/assembly/duo-oam-assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</dependencySets>
<files>
<file>
<source>./src/main/resources/DuoPlugin.xml</source>
<source>./src/main/resources/DuoUniversalPlugin.xml</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.duosecurity.Client;
import com.duosecurity.model.Token;

public class DuoPlugin extends AbstractAuthenticationPlugIn {
public class DuoUniversalPlugin extends AbstractAuthenticationPlugIn {

private static final String JAR_VERSION = "1.0.0";
private static final String CLIENT_ID_PARAM = "Client ID";
Expand Down Expand Up @@ -358,7 +358,7 @@ public void setMonitoringStatus(final boolean status) {

@Override
public String getPluginName() {
return "DuoPlugin";
return "DuoUniversalPlugin";
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Plugin name="DuoPlugin" type="Authentication">
<Plugin name="DuoUniversalPlugin" type="Authentication">
<author>Duo Security</author>
<email>[email protected]</email>
<creationDate>12:00:00 2021-01-20</creationDate>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-Version: 10
Bundle-Name: DuoPlugin
Bundle-Activator: com.duosecurity.plugin.DuoPlugin
Bundle-Name: DuoUniversalPlugin
Bundle-Activator: com.duosecurity.plugin.DuoUniversalPlugin
Bundle-ManifestVersion: 2
Import-Package: org.osgi.framework;version="1.3.0",oracle.security.am.plugin,oracle.security.am.plugin.authn,oracle.security.am.plugin.impl,oracle.security.am.plugin.api,oracle.security.am.common.utilities.principal,oracle.security.idm,javax.security.auth,oracle.security.am.engines.common.identity.provider,oracle.security.am.common.policy.runtime,javax.crypto,javax.crypto.spec,javax.net,javax.net.ssl,org.w3c.dom
Bundle-SymbolicName: DuoPlugin
Bundle-SymbolicName: DuoUniversalPlugin
77 changes: 0 additions & 77 deletions src/test/java/com/duosecurity/plugin/DuoPluginPhase1Test.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,52 @@

import static org.junit.jupiter.api.Assertions.*;

public class DuoPluginConfigTest {
DuoPlugin duoPlugin;
public class DuoUniversalPluginConfigTest {
DuoUniversalPlugin duoUniversalPlugin;

@BeforeEach
public void setUp() {
duoPlugin = new DuoPlugin();
duoPlugin.username = "tester";
duoPlugin.client_id = "DIXXXXXXXXXXXXXXXXXX";
duoPlugin.client_secret = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
duoPlugin.host = "fakehosturl";
duoUniversalPlugin = new DuoUniversalPlugin();
duoUniversalPlugin.username = "tester";
duoUniversalPlugin.client_id = "DIXXXXXXXXXXXXXXXXXX";
duoUniversalPlugin.client_secret = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
duoUniversalPlugin.host = "fakehosturl";
}

@Test
public void testGetDescription() {
String ret_description = duoPlugin.getDescription();
String ret_description = duoUniversalPlugin.getDescription();
String description = "Duo Security's Plugin to allow users to 2FA with Duo";
assertEquals(description, ret_description);
}

@Test
public void testGetMonitoringData() {
Map data = duoPlugin.getMonitoringData();
Map data = duoUniversalPlugin.getMonitoringData();
assertNull(data);
}

@Test
public void testGetMonitoringStatus() {
boolean data = duoPlugin.getMonitoringStatus();
boolean data = duoUniversalPlugin.getMonitoringStatus();
assertFalse(data);
}

@Test
public void testGetPluginName() {
String data = duoPlugin.getPluginName();
assertEquals(data, "DuoPlugin");
String data = duoUniversalPlugin.getPluginName();
assertEquals(data, "DuoUniversalPlugin");
}

@Test
public void testGetRevision() {
int data = duoPlugin.getRevision();
int data = duoUniversalPlugin.getRevision();
assertEquals(data, 0);
}

@Test
public void testGetUserAgent() {
String ua = duoPlugin.getUserAgent();
String ua = duoUniversalPlugin.getUserAgent();
assertNotNull(ua);
assertTrue(ua.toLowerCase().contains("duo_universal_oam/"));
assertTrue(ua.toLowerCase().contains("java.version"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DuoPluginFailmodeTest {
DuoPlugin duoPlugin;
public class DuoUniversalPluginFailmodeTest {
DuoUniversalPlugin duoUniversalPlugin;
Client duoClient;
HealthCheckResponse hcResponse;

@BeforeEach
public void setUp() {
duoPlugin = new DuoPlugin();
duoUniversalPlugin = new DuoUniversalPlugin();
duoClient = Mockito.mock(Client.class);
hcResponse = Mockito.mock(HealthCheckResponse.class);
}
Expand All @@ -30,7 +30,7 @@ public void testDuoHealthy() throws DuoException {
Mockito.when(hcResponse.wasSuccess()).thenReturn(Boolean.TRUE);
Mockito.when(duoClient.healthCheck()).thenReturn(hcResponse);

boolean result = duoPlugin.isDuoHealthy(duoClient);
boolean result = duoUniversalPlugin.isDuoHealthy(duoClient);

assertEquals(true, result);
}
Expand All @@ -40,7 +40,7 @@ public void testDuoUnhealthy() throws DuoException {
Mockito.when(hcResponse.wasSuccess()).thenReturn(Boolean.FALSE);
Mockito.when(duoClient.healthCheck()).thenReturn(hcResponse);

boolean result = duoPlugin.isDuoHealthy(duoClient);
boolean result = duoUniversalPlugin.isDuoHealthy(duoClient);

assertEquals(false, result);
}
Expand All @@ -49,7 +49,7 @@ public void testDuoUnhealthy() throws DuoException {
public void testDuoHealthCheckException() throws DuoException {
Mockito.when(duoClient.healthCheck()).thenThrow(new DuoException("health check exception"));

boolean result = duoPlugin.isDuoHealthy(duoClient);
boolean result = duoUniversalPlugin.isDuoHealthy(duoClient);

assertEquals(false, result);
}
Expand All @@ -60,82 +60,82 @@ public void testDuoHealthyFailOpen() throws DuoException {
Mockito.when(hcResponse.wasSuccess()).thenReturn(Boolean.TRUE);
Mockito.when(duoClient.healthCheck()).thenReturn(hcResponse);

DuoPlugin.FailmodeResult result = duoPlugin.performHealthCheckAndFailmode(duoClient, DuoPlugin.Failmode.OPEN);
DuoUniversalPlugin.FailmodeResult result = duoUniversalPlugin.performHealthCheckAndFailmode(duoClient, DuoUniversalPlugin.Failmode.OPEN);

assertEquals(DuoPlugin.FailmodeResult.AUTH, result);
assertEquals(DuoUniversalPlugin.FailmodeResult.AUTH, result);
}

@Test
public void testDuoUnhealthyFailOpen() throws DuoException {
Mockito.when(hcResponse.wasSuccess()).thenReturn(Boolean.FALSE);
Mockito.when(duoClient.healthCheck()).thenReturn(hcResponse);

DuoPlugin.FailmodeResult result = duoPlugin.performHealthCheckAndFailmode(duoClient, DuoPlugin.Failmode.OPEN);
DuoUniversalPlugin.FailmodeResult result = duoUniversalPlugin.performHealthCheckAndFailmode(duoClient, DuoUniversalPlugin.Failmode.OPEN);

assertEquals(DuoPlugin.FailmodeResult.ALLOW, result);
assertEquals(DuoUniversalPlugin.FailmodeResult.ALLOW, result);
}

@Test
public void testDuoUnhealthyFailClosed() throws DuoException {
Mockito.when(hcResponse.wasSuccess()).thenReturn(Boolean.FALSE);
Mockito.when(duoClient.healthCheck()).thenReturn(hcResponse);

DuoPlugin.FailmodeResult result = duoPlugin.performHealthCheckAndFailmode(duoClient, DuoPlugin.Failmode.CLOSED);
DuoUniversalPlugin.FailmodeResult result = duoUniversalPlugin.performHealthCheckAndFailmode(duoClient, DuoUniversalPlugin.Failmode.CLOSED);

assertEquals(DuoPlugin.FailmodeResult.BLOCK, result);
assertEquals(DuoUniversalPlugin.FailmodeResult.BLOCK, result);
}

@Test
public void testNullFailmodeConfig() {
Object configParam = null;

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.CLOSED, result);
assertEquals(DuoUniversalPlugin.Failmode.CLOSED, result);
}

@Test
public void testNonStringFailmodeConfig() {
Integer configParam = 7;

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.CLOSED, result);
assertEquals(DuoUniversalPlugin.Failmode.CLOSED, result);
}

@Test
public void testNonsenseFailmodeConfig() {
String configParam = "not a failmode";

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.CLOSED, result);
assertEquals(DuoUniversalPlugin.Failmode.CLOSED, result);
}

@Test
public void testClosedFailmodeConfig() {
String configParam = "closed";

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.CLOSED, result);
assertEquals(DuoUniversalPlugin.Failmode.CLOSED, result);
}

@Test
public void testOpenFailmodeConfig() {
String configParam = "open";

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.OPEN, result);
assertEquals(DuoUniversalPlugin.Failmode.OPEN, result);
}

@Test
public void testOpenMixedCaseFailmodeConfig() {
String configParam = "oPen";

DuoPlugin.Failmode result = DuoPlugin.determineFailmode(configParam);
DuoUniversalPlugin.Failmode result = DuoUniversalPlugin.determineFailmode(configParam);

assertEquals(DuoPlugin.Failmode.OPEN, result);
assertEquals(DuoUniversalPlugin.Failmode.OPEN, result);
}
}
Loading

0 comments on commit e96cb3c

Please sign in to comment.