From 189fff82ea3e30fb566d58a6b349f833da714e85 Mon Sep 17 00:00:00 2001 From: aL118 Date: Fri, 23 Jun 2023 13:33:14 -0400 Subject: [PATCH 01/12] added blacklist function --- .../java/emissary/core/HDMobileAgent.java | 2 +- src/main/java/emissary/core/MobileAgent.java | 10 ++++- .../emissary/place/IServiceProviderPlace.java | 14 +++++++ .../emissary/place/ServiceProviderPlace.java | 19 +++++++++- .../java/emissary/core/MobileAgentTest.java | 38 +++++++++++++++++++ 5 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/main/java/emissary/core/HDMobileAgent.java b/src/main/java/emissary/core/HDMobileAgent.java index d6c39461d4..6b1485681b 100755 --- a/src/main/java/emissary/core/HDMobileAgent.java +++ b/src/main/java/emissary/core/HDMobileAgent.java @@ -395,7 +395,7 @@ protected void switchPrimaryPayload(final int i) { } /** - * Do work now that we have arrived a the specified place + * Do work now that we have arrived at the specified place * * @param place the place we are asking to work for us * @param payloadListArg list of IBaseDataObject for the place to operate on diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 04e5dd160d..61b1310c79 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -332,7 +332,7 @@ protected void agentControl(final IServiceProviderPlace currentPlaceArg) { } /** - * Do work now that we have arrived a the specified place + * Do work now that we have arrived at the specified place * * @param place the place we are asking to work for us * @param payloadArg the data for the place to operate on @@ -526,6 +526,14 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); + // if last place/directory entry is blacklisted in place, reject + if (place.getProxies().contains("*")) { + String entry = curEntry.getKey().substring(curEntry.getKey().lastIndexOf('/') + 1); + if (place.blacklisted(entry)) { + continue; + } + } + // Process through the parallel service type once per place max // no matter how many forms would route there if (curEntry != null && isParallelServiceType(curType)) { diff --git a/src/main/java/emissary/place/IServiceProviderPlace.java b/src/main/java/emissary/place/IServiceProviderPlace.java index de0fcb75b5..a8dc6dfae1 100755 --- a/src/main/java/emissary/place/IServiceProviderPlace.java +++ b/src/main/java/emissary/place/IServiceProviderPlace.java @@ -155,4 +155,18 @@ public interface IServiceProviderPlace { */ MobileAgent getAgent() throws NamespaceException; + /** + * Returns whether form is blacklisted + */ + boolean blacklisted(String s); + + /** + * Add to blacklist + */ + void addBlacklist(String s); + + /** + * Clear everything in blacklist + */ + void clearBlacklist(); } diff --git a/src/main/java/emissary/place/ServiceProviderPlace.java b/src/main/java/emissary/place/ServiceProviderPlace.java index 7e75d1b23e..f39d083de2 100755 --- a/src/main/java/emissary/place/ServiceProviderPlace.java +++ b/src/main/java/emissary/place/ServiceProviderPlace.java @@ -122,6 +122,11 @@ public abstract class ServiceProviderPlace implements emissary.place.IServicePro protected boolean processMethodImplemented = false; protected boolean processHDMethodImplemented = false; + /** + * Blacklist of place/directory entries for wildcard service proxy + */ + private List blackList = new ArrayList<>(); + /** * Create a place and register it in the local directory. The default config must contain at least one SERVICE_KEY * element used to know where that is and how to name it. If the old style config with SERVICE_PROXY etc is used then @@ -293,7 +298,7 @@ protected void setupPlace(String theDir, String placeLocation) throws IOExceptio } /** - * Get a local reference to the directpry. + * Get a local reference to the directory. * * @param theDir key for the directory to use, if null will look up default name * @return true if it worked @@ -1125,6 +1130,18 @@ protected IBaseDataObject getTLD() { return null; } + public boolean blacklisted(String s) { + return blackList.contains(s); + } + + public void addBlacklist(String s) { + blackList.add(s); + } + + public void clearBlacklist() { + blackList.clear(); + } + /** * This method should return a list of all the parameters that a subclass Place will potentially modify (this includes * adding, removing, or changing the value of). diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index d05d27522c..e55b8dcc5a 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -76,6 +76,44 @@ void testAddParrallelTrackingInfo() { assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); } + @Test + void testBlacklist() throws Exception { + IBaseDataObject d = DataObjectFactory.getInstance(); + HDMobileAgent agent = new MobileAgentTest.MobAg(); + HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.core.FakePlace.cfg"); + + // blacklist one + place.addBlacklist("FoodPlace"); + d.setCurrentForm("THECF"); + d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d); + d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); + agent.getNextKey(place, d); + assertEquals(1, agent.visitedPlaces.size(), "FOOD should not have been added"); + assertTrue(agent.visitedPlaces.contains("FOO") && !agent.visitedPlaces.contains("FOOD"), "FOOD should not have been added"); + + // blacklisting both + agent.clear(); + place.addBlacklist("FooPlace"); + d.clearTransformHistory(); + d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d); + d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); + agent.getNextKey(place, d); + assertEquals(0, agent.visitedPlaces.size(), "Nothing should have been added"); + + // nothing is blacklisted + agent.clear(); + place.clearBlacklist(); + d.clearTransformHistory(); + d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d); + d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); + agent.getNextKey(place, d); + assertEquals(2, agent.visitedPlaces.size(), "FOO and FOOD should have both been added"); + assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); + } + static final class MobAg extends HDMobileAgent { static final long serialVersionUID = 102211824991899593L; From a07a7107c5f110fea92ae021d45ad4d1e5a012e4 Mon Sep 17 00:00:00 2001 From: aL118 Date: Fri, 23 Jun 2023 14:34:52 -0400 Subject: [PATCH 02/12] accounting for edge case --- src/main/java/emissary/core/MobileAgent.java | 13 +++++--- .../java/emissary/core/MobileAgentTest.java | 31 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 61b1310c79..09b11e3a6a 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,14 +526,17 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if last place/directory entry is blacklisted in place, reject - if (place.getProxies().contains("*")) { - String entry = curEntry.getKey().substring(curEntry.getKey().lastIndexOf('/') + 1); - if (place.blacklisted(entry)) { - continue; + // if last place/directory entry is blacklisted and not specified, reject + if (curEntry != null) { + String entry = curEntry.getServiceName(); + if (place.getProxies().contains("*") && !place.getProxies().contains(entry)) { + if (place.blacklisted(entry)) { + continue; + } } } + // Process through the parallel service type once per place max // no matter how many forms would route there if (curEntry != null && isParallelServiceType(curType)) { diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index e55b8dcc5a..4796b40946 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -78,12 +78,10 @@ void testAddParrallelTrackingInfo() { @Test void testBlacklist() throws Exception { - IBaseDataObject d = DataObjectFactory.getInstance(); - HDMobileAgent agent = new MobileAgentTest.MobAg(); HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.core.FakePlace.cfg"); // blacklist one - place.addBlacklist("FoodPlace"); + place.addBlacklist("FOOD"); d.setCurrentForm("THECF"); d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); agent.getNextKey(place, d); @@ -92,16 +90,6 @@ void testBlacklist() throws Exception { assertEquals(1, agent.visitedPlaces.size(), "FOOD should not have been added"); assertTrue(agent.visitedPlaces.contains("FOO") && !agent.visitedPlaces.contains("FOOD"), "FOOD should not have been added"); - // blacklisting both - agent.clear(); - place.addBlacklist("FooPlace"); - d.clearTransformHistory(); - d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d); - d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); - agent.getNextKey(place, d); - assertEquals(0, agent.visitedPlaces.size(), "Nothing should have been added"); - // nothing is blacklisted agent.clear(); place.clearBlacklist(); @@ -112,6 +100,23 @@ void testBlacklist() throws Exception { agent.getNextKey(place, d); assertEquals(2, agent.visitedPlaces.size(), "FOO and FOOD should have both been added"); assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); + + place.shutDown(); + } + + @Test + void testBlacklistEdgeCase() throws Exception { + HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.core.FakePlace.cfg"); + place.addServiceProxy("FOOD"); + place.addBlacklist("FOOD"); + d.setCurrentForm("THECF"); + d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d); + + assertEquals(1, agent.visitedPlaces.size(), "FOOD should have been added"); + assertTrue(agent.visitedPlaces.contains("FOOD"), "FOOD should have been added"); + + place.shutDown(); } static final class MobAg extends HDMobileAgent { From 98d0f433240655ece77cb0d58ecd83ea5d12dd73 Mon Sep 17 00:00:00 2001 From: aL118 Date: Fri, 23 Jun 2023 14:46:40 -0400 Subject: [PATCH 03/12] removed case --- src/main/java/emissary/core/MobileAgent.java | 4 ++-- src/test/java/emissary/core/MobileAgentTest.java | 15 --------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 09b11e3a6a..d8211d548b 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,10 +526,10 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if last place/directory entry is blacklisted and not specified, reject + // if last place/directory entry is blacklisted, reject if (curEntry != null) { String entry = curEntry.getServiceName(); - if (place.getProxies().contains("*") && !place.getProxies().contains(entry)) { + if (place.getProxies().contains("*")) { if (place.blacklisted(entry)) { continue; } diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index 4796b40946..b52bfc4b7b 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -104,21 +104,6 @@ void testBlacklist() throws Exception { place.shutDown(); } - @Test - void testBlacklistEdgeCase() throws Exception { - HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.core.FakePlace.cfg"); - place.addServiceProxy("FOOD"); - place.addBlacklist("FOOD"); - d.setCurrentForm("THECF"); - d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d); - - assertEquals(1, agent.visitedPlaces.size(), "FOOD should have been added"); - assertTrue(agent.visitedPlaces.contains("FOOD"), "FOOD should have been added"); - - place.shutDown(); - } - static final class MobAg extends HDMobileAgent { static final long serialVersionUID = 102211824991899593L; From 1c6a7d560539125141df8a4c98bf02b1a67a09b6 Mon Sep 17 00:00:00 2001 From: aL118 Date: Mon, 26 Jun 2023 17:00:45 -0400 Subject: [PATCH 04/12] fix to disallowList --- src/main/java/emissary/core/MobileAgent.java | 11 -------- .../core/constants/Configurations.java | 2 ++ .../emissary/place/IServiceProviderPlace.java | 14 ++-------- .../emissary/place/ServiceProviderPlace.java | 28 +++++++++---------- .../java/emissary/core/MobileAgentTest.java | 28 ------------------- .../place/ServiceProviderPlaceTest.java | 21 +++++++++++--- 6 files changed, 34 insertions(+), 70 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index d8211d548b..25198267d1 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,17 +526,6 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if last place/directory entry is blacklisted, reject - if (curEntry != null) { - String entry = curEntry.getServiceName(); - if (place.getProxies().contains("*")) { - if (place.blacklisted(entry)) { - continue; - } - } - } - - // Process through the parallel service type once per place max // no matter how many forms would route there if (curEntry != null && isParallelServiceType(curType)) { diff --git a/src/main/java/emissary/core/constants/Configurations.java b/src/main/java/emissary/core/constants/Configurations.java index 3e7304f8ad..1025098945 100644 --- a/src/main/java/emissary/core/constants/Configurations.java +++ b/src/main/java/emissary/core/constants/Configurations.java @@ -22,6 +22,7 @@ public class Configurations { public static final String SERVICE_QUALITY = "SERVICE_QUALITY"; public static final String SERVICE_PROXY = "SERVICE_PROXY"; public static final String SERVICE_KEY = "SERVICE_KEY"; + public static final String SERVICE_PROXY_DISALLOW = "SERVICE_PROXY_DISALLOW"; /** * The list of reserved service config keys for service/place creation @@ -34,6 +35,7 @@ public class Configurations { SERVICE_KEY, SERVICE_NAME, SERVICE_PROXY, + SERVICE_PROXY_DISALLOW, SERVICE_QUALITY, SERVICE_TYPE)); diff --git a/src/main/java/emissary/place/IServiceProviderPlace.java b/src/main/java/emissary/place/IServiceProviderPlace.java index a8dc6dfae1..96af050da4 100755 --- a/src/main/java/emissary/place/IServiceProviderPlace.java +++ b/src/main/java/emissary/place/IServiceProviderPlace.java @@ -156,17 +156,7 @@ public interface IServiceProviderPlace { MobileAgent getAgent() throws NamespaceException; /** - * Returns whether form is blacklisted + * Returns whether form is disallowed */ - boolean blacklisted(String s); - - /** - * Add to blacklist - */ - void addBlacklist(String s); - - /** - * Clear everything in blacklist - */ - void clearBlacklist(); + boolean isDisallowed(String s); } diff --git a/src/main/java/emissary/place/ServiceProviderPlace.java b/src/main/java/emissary/place/ServiceProviderPlace.java index f39d083de2..0f934cadab 100755 --- a/src/main/java/emissary/place/ServiceProviderPlace.java +++ b/src/main/java/emissary/place/ServiceProviderPlace.java @@ -51,6 +51,7 @@ import static emissary.core.constants.Configurations.SERVICE_KEY; import static emissary.core.constants.Configurations.SERVICE_NAME; import static emissary.core.constants.Configurations.SERVICE_PROXY; +import static emissary.core.constants.Configurations.SERVICE_PROXY_DISALLOW; import static emissary.core.constants.Configurations.SERVICE_QUALITY; import static emissary.core.constants.Configurations.SERVICE_TYPE; @@ -86,6 +87,11 @@ public abstract class ServiceProviderPlace implements emissary.place.IServicePro */ protected List keys = new ArrayList<>(); + /** + * List of disallowed places in SERVICE_PROXY_DISALLOW + */ + protected List disallowList = new ArrayList<>(); + // Items that are going to be deprecated, but here now to // make the transition easier, for compatibility protected String myKey = null; @@ -122,11 +128,6 @@ public abstract class ServiceProviderPlace implements emissary.place.IServicePro protected boolean processMethodImplemented = false; protected boolean processHDMethodImplemented = false; - /** - * Blacklist of place/directory entries for wildcard service proxy - */ - private List blackList = new ArrayList<>(); - /** * Create a place and register it in the local directory. The default config must contain at least one SERVICE_KEY * element used to know where that is and how to name it. If the old style config with SERVICE_PROXY etc is used then @@ -443,6 +444,11 @@ protected void configureServicePlace(@Nullable String placeLocation) throws IOEx DirectoryEntry de = new DirectoryEntry(sp, serviceName, serviceType, locationPart, serviceDescription, serviceCost, serviceQuality); keys.add(de.getFullKey()); } + // pick up the disallowed proxies(save full 4-tuple keys!) + for (String sp : configG.findEntries(SERVICE_PROXY_DISALLOW)) { + DirectoryEntry de = new DirectoryEntry(sp, serviceName, serviceType, locationPart, serviceDescription, serviceCost, serviceQuality); + disallowList.add(de.getDataType()); + } } else { // May be configured the new way, but warn if there is a mixture of // null and non-null items using the old-fashioned way. Perhaps the @@ -1130,16 +1136,8 @@ protected IBaseDataObject getTLD() { return null; } - public boolean blacklisted(String s) { - return blackList.contains(s); - } - - public void addBlacklist(String s) { - blackList.add(s); - } - - public void clearBlacklist() { - blackList.clear(); + public boolean isDisallowed(String s) { + return disallowList.contains(s); } /** diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index b52bfc4b7b..d05d27522c 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -76,34 +76,6 @@ void testAddParrallelTrackingInfo() { assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); } - @Test - void testBlacklist() throws Exception { - HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.core.FakePlace.cfg"); - - // blacklist one - place.addBlacklist("FOOD"); - d.setCurrentForm("THECF"); - d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d); - d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); - agent.getNextKey(place, d); - assertEquals(1, agent.visitedPlaces.size(), "FOOD should not have been added"); - assertTrue(agent.visitedPlaces.contains("FOO") && !agent.visitedPlaces.contains("FOOD"), "FOOD should not have been added"); - - // nothing is blacklisted - agent.clear(); - place.clearBlacklist(); - d.clearTransformHistory(); - d.appendTransformHistory("UNKNOWN.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d); - d.appendTransformHistory("UNKNOWN.FOO.ANALYZE.http://localhost:8005/FooPlace$1234"); - agent.getNextKey(place, d); - assertEquals(2, agent.visitedPlaces.size(), "FOO and FOOD should have both been added"); - assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); - - place.shutDown(); - } - static final class MobAg extends HDMobileAgent { static final long serialVersionUID = 102211824991899593L; diff --git a/src/test/java/emissary/place/ServiceProviderPlaceTest.java b/src/test/java/emissary/place/ServiceProviderPlaceTest.java index 894244240b..46a5d53437 100644 --- a/src/test/java/emissary/place/ServiceProviderPlaceTest.java +++ b/src/test/java/emissary/place/ServiceProviderPlaceTest.java @@ -1,10 +1,7 @@ package emissary.place; import emissary.config.ConfigUtil; -import emissary.core.BaseDataObject; -import emissary.core.EmissaryException; -import emissary.core.IBaseDataObject; -import emissary.core.Namespace; +import emissary.core.*; import emissary.directory.DirectoryEntry; import emissary.directory.KeyManipulator; import emissary.test.core.junit5.UnitTest; @@ -69,6 +66,11 @@ class ServiceProviderPlaceTest extends UnitTest { private static final byte[] configBadKeyData = ("TGT_HOST = \"localhost\"\n" + "TGT_PORT = \"8001\"\n" + "SERVICE_KEY = \"TP4.TNAME.http://@{TGT_HOST}:@{TGT_PORT}/TPlaceName$8050\"\n" + "SERVICE_DESCRIPTION = \"bogus\"\n").getBytes(); + private static final byte[] configDisallowedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY2\"\n" + + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY3\"\n").getBytes(); + String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY); @Override @@ -531,6 +533,17 @@ void testBogusKeyRemoval() { } } + @Test + void testDisallowedServiceProxy() throws Exception { + InputStream config2 = new ByteArrayInputStream(configDisallowedData); + IServiceProviderPlace p = new PlaceTest(config2); + assertEquals("PlaceTest", p.getPlaceName(), "Configured place name"); + System.out.println(p.getPrimaryProxy()); + assertTrue(p.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be disallowed"); + assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); + assertTrue(p.isDisallowed("TEST_SERVICE_PROXY3"), "TEST_SERVICE_PROXY3 should be disallowed"); + } + private static final class PlaceTest extends ServiceProviderPlace { public PlaceTest() throws IOException { From 5e4067f4eb166fbdae005c9494c096b494c9742c Mon Sep 17 00:00:00 2001 From: aL118 Date: Tue, 27 Jun 2023 10:30:30 -0400 Subject: [PATCH 05/12] adjust test --- .../place/ServiceProviderPlaceTest.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/test/java/emissary/place/ServiceProviderPlaceTest.java b/src/test/java/emissary/place/ServiceProviderPlaceTest.java index 46a5d53437..a8919a99c2 100644 --- a/src/test/java/emissary/place/ServiceProviderPlaceTest.java +++ b/src/test/java/emissary/place/ServiceProviderPlaceTest.java @@ -1,7 +1,10 @@ package emissary.place; import emissary.config.ConfigUtil; -import emissary.core.*; +import emissary.core.BaseDataObject; +import emissary.core.EmissaryException; +import emissary.core.IBaseDataObject; +import emissary.core.Namespace; import emissary.directory.DirectoryEntry; import emissary.directory.KeyManipulator; import emissary.test.core.junit5.UnitTest; @@ -69,7 +72,13 @@ class ServiceProviderPlaceTest extends UnitTest { private static final byte[] configDisallowedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY2\"\n" - + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY3\"\n").getBytes(); + + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY3\"\n" + + "SERVICE_PROXY_DISALLOW != \"TEST_SERVICE_PROXY3\"\n").getBytes(); + + private static final byte[] configDisallowedData2 = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW != \"*\"\n").getBytes(); String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY); @@ -534,14 +543,22 @@ void testBogusKeyRemoval() { } @Test - void testDisallowedServiceProxy() throws Exception { - InputStream config2 = new ByteArrayInputStream(configDisallowedData); - IServiceProviderPlace p = new PlaceTest(config2); - assertEquals("PlaceTest", p.getPlaceName(), "Configured place name"); - System.out.println(p.getPrimaryProxy()); - assertTrue(p.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be disallowed"); - assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); - assertTrue(p.isDisallowed("TEST_SERVICE_PROXY3"), "TEST_SERVICE_PROXY3 should be disallowed"); + void testDisallowedServiceProxy() { + try { + InputStream config = new ByteArrayInputStream(configDisallowedData); + IServiceProviderPlace p = new PlaceTest(config); + assertEquals("PlaceTest", p.getPlaceName(), "Configured place name"); + assertTrue(p.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be disallowed"); + assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); + assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY3"), "TEST_SERVICE_PROXY3 should be allowed"); + + InputStream config2 = new ByteArrayInputStream(configDisallowedData2); + IServiceProviderPlace p2 = new PlaceTest(config2); + assertTrue(!p2.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be allowed"); + assertTrue(!p2.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); + } catch (IOException iox) { + fail("Place should have configured with SERVICE_KEY", iox); + } } private static final class PlaceTest extends ServiceProviderPlace { From 8af79dd5694721e6038948f20e77911ae4642602 Mon Sep 17 00:00:00 2001 From: aL118 Date: Tue, 27 Jun 2023 13:47:26 -0400 Subject: [PATCH 06/12] added back checking in MobileAgent --- src/main/java/emissary/core/MobileAgent.java | 5 +++ .../emissary/place/sample/DisallowPlace.cfg | 12 +++++++ .../java/emissary/core/MobileAgentTest.java | 35 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/main/resources/emissary/place/sample/DisallowPlace.cfg diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 25198267d1..bf98aea622 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,6 +526,11 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); + // if last place/directory entry is disallowed, reject + if (curEntry != null && place.isDisallowed(curEntry.getDataType())) { + continue; + } + // Process through the parallel service type once per place max // no matter how many forms would route there if (curEntry != null && isParallelServiceType(curType)) { diff --git a/src/main/resources/emissary/place/sample/DisallowPlace.cfg b/src/main/resources/emissary/place/sample/DisallowPlace.cfg new file mode 100644 index 0000000000..3fcdd7c5cc --- /dev/null +++ b/src/main/resources/emissary/place/sample/DisallowPlace.cfg @@ -0,0 +1,12 @@ +PLACE_NAME = "DisallowPlace" +SERVICE_NAME = "TO_UPPER" +SERVICE_TYPE = "TRANSFORM" +SERVICE_DESCRIPTION = "using disallow" +SERVICE_COST = 50 +SERVICE_QUALITY = 90 + +NEW_FORM ="UPPER_CASE" +END_FORM ="FINI" + +SERVICE_PROXY = "LOWER_CASE" +SERVICE_PROXY_DISALLOW = "B" \ No newline at end of file diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index d05d27522c..463eeaf493 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -76,6 +76,25 @@ void testAddParrallelTrackingInfo() { assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO", "FOOD")), "FOO and FOOD should have both been added"); } + @Test + void testDisallowedList() throws Exception { + // setup + HDMobileAgent agent = new MobAg2(); + HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.place.sample.DisallowPlace.cfg"); + d.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d); + d.appendTransformHistory("A.FOO1.ANALYZE.http://localhost:8005/FooPlace$1234"); + agent.getNextKey(place, d); + d.appendTransformHistory("B.FOO2.ANALYZE.http://localhost:8005/FooPlace$1234"); + agent.getNextKey(place, d); + + // verify + assertEquals(2, agent.visitedPlaces.size(), "FOO2 should not have been added"); + assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO1", "FOO3")), "FOO1 and FOO3 should have both been added"); + agent.killAgent(); + place.shutDown(); + } + static final class MobAg extends HDMobileAgent { static final long serialVersionUID = 102211824991899593L; @@ -98,4 +117,20 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServic } } } + + static final class MobAg2 extends HDMobileAgent { + @Override + protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServiceProviderPlace place, final DirectoryEntry lastEntry, + final IBaseDataObject payloadArg) { + if (lastEntry.getDataType().equalsIgnoreCase("S")) { + return new DirectoryEntry("A.FOO1.ANALYZE.http://localhost:8005/FooPlace$1234"); + } else if (lastEntry.getDataType().equalsIgnoreCase("A")) { + return new DirectoryEntry("B.FOO2.ANALYZE.http://localhost:8005/FooPlace$1234"); + } else if (lastEntry.getDataType().equalsIgnoreCase("B")) { + return new DirectoryEntry("C.FOO3.ANALYZE.http://localhost:8005/FooPlace$1234"); + } else { + return null; + } + } + } } From 3d34523e0d25614f9e2e2d87d9e08a0160386bfc Mon Sep 17 00:00:00 2001 From: aL118 Date: Tue, 27 Jun 2023 14:20:40 -0400 Subject: [PATCH 07/12] refactored config to not need separate file --- .../emissary/place/sample/DisallowPlace.cfg | 12 ------------ src/test/java/emissary/core/MobileAgentTest.java | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 src/main/resources/emissary/place/sample/DisallowPlace.cfg diff --git a/src/main/resources/emissary/place/sample/DisallowPlace.cfg b/src/main/resources/emissary/place/sample/DisallowPlace.cfg deleted file mode 100644 index 3fcdd7c5cc..0000000000 --- a/src/main/resources/emissary/place/sample/DisallowPlace.cfg +++ /dev/null @@ -1,12 +0,0 @@ -PLACE_NAME = "DisallowPlace" -SERVICE_NAME = "TO_UPPER" -SERVICE_TYPE = "TRANSFORM" -SERVICE_DESCRIPTION = "using disallow" -SERVICE_COST = 50 -SERVICE_QUALITY = 90 - -NEW_FORM ="UPPER_CASE" -END_FORM ="FINI" - -SERVICE_PROXY = "LOWER_CASE" -SERVICE_PROXY_DISALLOW = "B" \ No newline at end of file diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index 463eeaf493..f9ee938555 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -3,12 +3,16 @@ import emissary.admin.PlaceStarter; import emissary.directory.DirectoryEntry; import emissary.place.IServiceProviderPlace; +import emissary.place.ServiceProviderPlace; import emissary.test.core.junit5.UnitTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -79,8 +83,12 @@ void testAddParrallelTrackingInfo() { @Test void testDisallowedList() throws Exception { // setup + byte[] configDisallowedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"B\"\n").getBytes(); + InputStream config = new ByteArrayInputStream(configDisallowedData); + IServiceProviderPlace place = new PlaceTest(config); HDMobileAgent agent = new MobAg2(); - HDMobileAgentTest.SimplePlace place = new HDMobileAgentTest.SimplePlace("emissary.place.sample.DisallowPlace.cfg"); d.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); agent.getNextKey(place, d); d.appendTransformHistory("A.FOO1.ANALYZE.http://localhost:8005/FooPlace$1234"); @@ -133,4 +141,10 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServic } } } + + private static final class PlaceTest extends ServiceProviderPlace { + public PlaceTest(InputStream config) throws IOException { + super(config); + } + } } From c928c5a05bef317e53858d9ef8930a6ab661014e Mon Sep 17 00:00:00 2001 From: aL118 Date: Fri, 14 Jul 2023 14:29:46 -0400 Subject: [PATCH 08/12] disallow replaced with deny --- src/main/java/emissary/core/MobileAgent.java | 4 +-- .../core/constants/Configurations.java | 4 +-- .../emissary/place/IServiceProviderPlace.java | 4 +-- .../emissary/place/ServiceProviderPlace.java | 16 +++++----- .../java/emissary/core/MobileAgentTest.java | 10 +++---- .../place/ServiceProviderPlaceTest.java | 30 +++++++++---------- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index bf98aea622..0f2c8abd65 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,8 +526,8 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if last place/directory entry is disallowed, reject - if (curEntry != null && place.isDisallowed(curEntry.getDataType())) { + // if last place/directory entry is denied, reject + if (curEntry != null && place.isDenied(curEntry.getDataType())) { continue; } diff --git a/src/main/java/emissary/core/constants/Configurations.java b/src/main/java/emissary/core/constants/Configurations.java index 1025098945..243d0c9475 100644 --- a/src/main/java/emissary/core/constants/Configurations.java +++ b/src/main/java/emissary/core/constants/Configurations.java @@ -22,7 +22,7 @@ public class Configurations { public static final String SERVICE_QUALITY = "SERVICE_QUALITY"; public static final String SERVICE_PROXY = "SERVICE_PROXY"; public static final String SERVICE_KEY = "SERVICE_KEY"; - public static final String SERVICE_PROXY_DISALLOW = "SERVICE_PROXY_DISALLOW"; + public static final String SERVICE_PROXY_DENY = "SERVICE_PROXY_DENY"; /** * The list of reserved service config keys for service/place creation @@ -35,7 +35,7 @@ public class Configurations { SERVICE_KEY, SERVICE_NAME, SERVICE_PROXY, - SERVICE_PROXY_DISALLOW, + SERVICE_PROXY_DENY, SERVICE_QUALITY, SERVICE_TYPE)); diff --git a/src/main/java/emissary/place/IServiceProviderPlace.java b/src/main/java/emissary/place/IServiceProviderPlace.java index 96af050da4..b28ced47ba 100755 --- a/src/main/java/emissary/place/IServiceProviderPlace.java +++ b/src/main/java/emissary/place/IServiceProviderPlace.java @@ -156,7 +156,7 @@ public interface IServiceProviderPlace { MobileAgent getAgent() throws NamespaceException; /** - * Returns whether form is disallowed + * Returns whether form is denied */ - boolean isDisallowed(String s); + boolean isDenied(String s); } diff --git a/src/main/java/emissary/place/ServiceProviderPlace.java b/src/main/java/emissary/place/ServiceProviderPlace.java index 0f934cadab..62bb39aed1 100755 --- a/src/main/java/emissary/place/ServiceProviderPlace.java +++ b/src/main/java/emissary/place/ServiceProviderPlace.java @@ -51,7 +51,7 @@ import static emissary.core.constants.Configurations.SERVICE_KEY; import static emissary.core.constants.Configurations.SERVICE_NAME; import static emissary.core.constants.Configurations.SERVICE_PROXY; -import static emissary.core.constants.Configurations.SERVICE_PROXY_DISALLOW; +import static emissary.core.constants.Configurations.SERVICE_PROXY_DENY; import static emissary.core.constants.Configurations.SERVICE_QUALITY; import static emissary.core.constants.Configurations.SERVICE_TYPE; @@ -88,9 +88,9 @@ public abstract class ServiceProviderPlace implements emissary.place.IServicePro protected List keys = new ArrayList<>(); /** - * List of disallowed places in SERVICE_PROXY_DISALLOW + * List of denied places in SERVICE_PROXY_DENY */ - protected List disallowList = new ArrayList<>(); + protected List denyList = new ArrayList<>(); // Items that are going to be deprecated, but here now to // make the transition easier, for compatibility @@ -444,10 +444,10 @@ protected void configureServicePlace(@Nullable String placeLocation) throws IOEx DirectoryEntry de = new DirectoryEntry(sp, serviceName, serviceType, locationPart, serviceDescription, serviceCost, serviceQuality); keys.add(de.getFullKey()); } - // pick up the disallowed proxies(save full 4-tuple keys!) - for (String sp : configG.findEntries(SERVICE_PROXY_DISALLOW)) { + // pick up the denied proxies(save full 4-tuple keys!) + for (String sp : configG.findEntries(SERVICE_PROXY_DENY)) { DirectoryEntry de = new DirectoryEntry(sp, serviceName, serviceType, locationPart, serviceDescription, serviceCost, serviceQuality); - disallowList.add(de.getDataType()); + denyList.add(de.getDataType()); } } else { // May be configured the new way, but warn if there is a mixture of @@ -1136,8 +1136,8 @@ protected IBaseDataObject getTLD() { return null; } - public boolean isDisallowed(String s) { - return disallowList.contains(s); + public boolean isDenied(String s) { + return denyList.contains(s); } /** diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index f9ee938555..20bfad2f3b 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -81,12 +81,12 @@ void testAddParrallelTrackingInfo() { } @Test - void testDisallowedList() throws Exception { + void testDenyList() throws Exception { // setup - byte[] configDisallowedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" - + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" - + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"B\"\n").getBytes(); - InputStream config = new ByteArrayInputStream(configDisallowedData); + byte[] configDeniedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with denied list\"\n" + "SERVICE_COST = 60\n" + + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY = \"B\"\n").getBytes(); + InputStream config = new ByteArrayInputStream(configDeniedData); IServiceProviderPlace place = new PlaceTest(config); HDMobileAgent agent = new MobAg2(); d.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); diff --git a/src/test/java/emissary/place/ServiceProviderPlaceTest.java b/src/test/java/emissary/place/ServiceProviderPlaceTest.java index a8919a99c2..e5eab2ea7d 100644 --- a/src/test/java/emissary/place/ServiceProviderPlaceTest.java +++ b/src/test/java/emissary/place/ServiceProviderPlaceTest.java @@ -69,16 +69,16 @@ class ServiceProviderPlaceTest extends UnitTest { private static final byte[] configBadKeyData = ("TGT_HOST = \"localhost\"\n" + "TGT_PORT = \"8001\"\n" + "SERVICE_KEY = \"TP4.TNAME.http://@{TGT_HOST}:@{TGT_PORT}/TPlaceName$8050\"\n" + "SERVICE_DESCRIPTION = \"bogus\"\n").getBytes(); - private static final byte[] configDisallowedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" - + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + private static final byte[] configDeniedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with denied list\"\n" + "SERVICE_COST = 60\n" + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY2\"\n" - + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY3\"\n" - + "SERVICE_PROXY_DISALLOW != \"TEST_SERVICE_PROXY3\"\n").getBytes(); + + "SERVICE_PROXY_DENY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY = \"TEST_SERVICE_PROXY3\"\n" + + "SERVICE_PROXY_DENY != \"TEST_SERVICE_PROXY3\"\n").getBytes(); - private static final byte[] configDisallowedData2 = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" - + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with disallowed list\"\n" + "SERVICE_COST = 60\n" + private static final byte[] configDeniedData2 = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with denied list\"\n" + "SERVICE_COST = 60\n" + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" - + "SERVICE_PROXY_DISALLOW = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DISALLOW != \"*\"\n").getBytes(); + + "SERVICE_PROXY_DENY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY != \"*\"\n").getBytes(); String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY); @@ -543,19 +543,19 @@ void testBogusKeyRemoval() { } @Test - void testDisallowedServiceProxy() { + void testDeniedServiceProxy() { try { - InputStream config = new ByteArrayInputStream(configDisallowedData); + InputStream config = new ByteArrayInputStream(configDeniedData); IServiceProviderPlace p = new PlaceTest(config); assertEquals("PlaceTest", p.getPlaceName(), "Configured place name"); - assertTrue(p.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be disallowed"); - assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); - assertTrue(!p.isDisallowed("TEST_SERVICE_PROXY3"), "TEST_SERVICE_PROXY3 should be allowed"); + assertTrue(p.isDenied("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be denied"); + assertTrue(!p.isDenied("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); + assertTrue(!p.isDenied("TEST_SERVICE_PROXY3"), "TEST_SERVICE_PROXY3 should be allowed"); - InputStream config2 = new ByteArrayInputStream(configDisallowedData2); + InputStream config2 = new ByteArrayInputStream(configDeniedData2); IServiceProviderPlace p2 = new PlaceTest(config2); - assertTrue(!p2.isDisallowed("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be allowed"); - assertTrue(!p2.isDisallowed("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); + assertTrue(!p2.isDenied("TEST_SERVICE_PROXY"), "TEST_SERVICE_PROXY should be allowed"); + assertTrue(!p2.isDenied("TEST_SERVICE_PROXY2"), "TEST_SERVICE_PROXY2 should be allowed"); } catch (IOException iox) { fail("Place should have configured with SERVICE_KEY", iox); } From c13e775fb3772ead36cc86e8c1da8719c9580b05 Mon Sep 17 00:00:00 2001 From: aL118 Date: Wed, 26 Jul 2023 15:12:50 -0400 Subject: [PATCH 09/12] Fixed deny list check with tests --- src/main/java/emissary/core/MobileAgent.java | 13 +++- .../java/emissary/core/MobileAgentTest.java | 61 ++++++++++++++----- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 0f2c8abd65..910ee03b2c 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,8 +526,9 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if last place/directory entry is denied, reject - if (curEntry != null && place.isDenied(curEntry.getDataType())) { + // if next proposed place/directory entry is denied, reject + if (curEntry != null && curEntry.getLocalPlace() != null && curEntry.getLocalPlace().isDenied(form)) { + logger.warn("FORM {} is denied for place {}; continuing", form, curEntry.getLocalPlace().getPlaceName()); continue; } @@ -548,7 +549,13 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, formID = lastEntry.getDataID(); parallelEntryRejected = true; logger.debug("Rejecting parallel entry found for {}: visitedPlaces={}", lastEntry.getFullKey(), this.visitedPlaces); - curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); + DirectoryEntry entry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); + // if next proposed place/directory entry is denied, reject + if (entry != null && entry.getLocalPlace() != null && entry.getLocalPlace().isDenied(form)) { + logger.warn("FORM {} is denied for place {}; continuing", form, curEntry.getLocalPlace().getPlaceName()); + } else { + curEntry = entry; + } } else { addParallelTrackingInfo(curEntry.getServiceName()); logger.debug("Added parallel tracking = {}", this.visitedPlaces); diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index 20bfad2f3b..f169387b68 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -82,23 +82,41 @@ void testAddParrallelTrackingInfo() { @Test void testDenyList() throws Exception { - // setup - byte[] configDeniedData = ("PLACE_NAME = \"PlaceTest\"\n" + "SERVICE_NAME = \"TEST_SERVICE_NAME\"\n" - + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_DESCRIPTION = \"test place with denied list\"\n" + "SERVICE_COST = 60\n" - + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY = \"B\"\n").getBytes(); + byte[] configDeniedData = ("PLACE_NAME = \"DelayPlace\"\n" + "SERVICE_NAME = \"DELAY\"\n" + + "SERVICE_TYPE = \"STUDY\"\n" + "SERVICE_DESCRIPTION = \"delay stuff\"\n" + "SERVICE_COST = 99\n" + + "SERVICE_QUALITY = 50\n" + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"FINI\"\n").getBytes(); InputStream config = new ByteArrayInputStream(configDeniedData); IServiceProviderPlace place = new PlaceTest(config); HDMobileAgent agent = new MobAg2(); - d.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d); - d.appendTransformHistory("A.FOO1.ANALYZE.http://localhost:8005/FooPlace$1234"); - agent.getNextKey(place, d); - d.appendTransformHistory("B.FOO2.ANALYZE.http://localhost:8005/FooPlace$1234"); - agent.getNextKey(place, d); + + // test accepted + IBaseDataObject d1 = DataObjectFactory.getInstance(); + d1.setCurrentForm("THECF"); + d1.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d1); + + // test denied + IBaseDataObject d2 = DataObjectFactory.getInstance(); + d2.setCurrentForm("FINI"); + d2.appendTransformHistory("A.FOO1.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d2); + + // test upstream in parallel tracking + byte[] configDeniedData2 = ("PLACE_NAME = \"FilePickUpClient\"\n" + "SERVICE_NAME = \"DELAY\"\n" + + "SERVICE_TYPE = \"STUDY\"\n" + "SERVICE_DESCRIPTION = \"delay stuff\"\n" + "SERVICE_COST = 99\n" + + "SERVICE_QUALITY = 50\n" + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"THECF\"\n").getBytes(); + InputStream config2 = new ByteArrayInputStream(configDeniedData2); + PlaceStarter.createPlace("http://localhost:8005/FilePickUpClient", config2, + "emissary.pickup.file.FilePickUpClientTest$MyFilePickUpClient", null); + IBaseDataObject d3 = DataObjectFactory.getInstance(); + d3.setCurrentForm("THECF"); + d3.appendTransformHistory("B.FOO1.ANALYZE.http://localhost:8005/GarbagePlace$1234"); + agent.getNextKey(place, d3); // verify - assertEquals(2, agent.visitedPlaces.size(), "FOO2 should not have been added"); - assertTrue(agent.visitedPlaces.containsAll(Arrays.asList("FOO1", "FOO3")), "FOO1 and FOO3 should have both been added"); + assertEquals(1, agent.visitedPlaces.size(), "FOO2 and FOO3 should not have been added"); + assertTrue(agent.visitedPlaces.contains("FOO"), "Only FOO should have been added"); + agent.killAgent(); place.shutDown(); } @@ -127,15 +145,28 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServic } static final class MobAg2 extends HDMobileAgent { + private boolean hit = false; + @Override protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServiceProviderPlace place, final DirectoryEntry lastEntry, final IBaseDataObject payloadArg) { if (lastEntry.getDataType().equalsIgnoreCase("S")) { - return new DirectoryEntry("A.FOO1.ANALYZE.http://localhost:8005/FooPlace$1234"); + DirectoryEntry d = new DirectoryEntry("A.FOO.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); + d.isLocal(); + return d; } else if (lastEntry.getDataType().equalsIgnoreCase("A")) { - return new DirectoryEntry("B.FOO2.ANALYZE.http://localhost:8005/FooPlace$1234"); + DirectoryEntry d = new DirectoryEntry("B.FOO2.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); + d.isLocal(); + return d; } else if (lastEntry.getDataType().equalsIgnoreCase("B")) { - return new DirectoryEntry("C.FOO3.ANALYZE.http://localhost:8005/FooPlace$1234"); + DirectoryEntry d = new DirectoryEntry("C.FOO.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); + d.isLocal(); + return d; + } else if (!hit && lastEntry.getDataType().equalsIgnoreCase("THECF")) { + DirectoryEntry d = new DirectoryEntry("D.FOO3.ANALYZE.http://localhost:8005/FilePickUpClient"); + d.isLocal(); + hit = true; + return d; } else { return null; } From 5bcb7bf7a8206ad653f74cde0c74acd8bb6956e0 Mon Sep 17 00:00:00 2001 From: aL118 Date: Mon, 31 Jul 2023 17:07:56 -0400 Subject: [PATCH 10/12] Moved check to DirectoryPlace --- src/main/java/emissary/core/MobileAgent.java | 14 +--- .../emissary/directory/DirectoryPlace.java | 7 ++ .../java/emissary/core/MobileAgentTest.java | 73 +++++-------------- 3 files changed, 27 insertions(+), 67 deletions(-) diff --git a/src/main/java/emissary/core/MobileAgent.java b/src/main/java/emissary/core/MobileAgent.java index 910ee03b2c..25198267d1 100755 --- a/src/main/java/emissary/core/MobileAgent.java +++ b/src/main/java/emissary/core/MobileAgent.java @@ -526,12 +526,6 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, String formID = form + KeyManipulator.DATAIDSEPARATOR + stageName; curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if next proposed place/directory entry is denied, reject - if (curEntry != null && curEntry.getLocalPlace() != null && curEntry.getLocalPlace().isDenied(form)) { - logger.warn("FORM {} is denied for place {}; continuing", form, curEntry.getLocalPlace().getPlaceName()); - continue; - } - // Process through the parallel service type once per place max // no matter how many forms would route there if (curEntry != null && isParallelServiceType(curType)) { @@ -549,13 +543,7 @@ protected DirectoryEntry getNextKey(@Nullable final IServiceProviderPlace place, formID = lastEntry.getDataID(); parallelEntryRejected = true; logger.debug("Rejecting parallel entry found for {}: visitedPlaces={}", lastEntry.getFullKey(), this.visitedPlaces); - DirectoryEntry entry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); - // if next proposed place/directory entry is denied, reject - if (entry != null && entry.getLocalPlace() != null && entry.getLocalPlace().isDenied(form)) { - logger.warn("FORM {} is denied for place {}; continuing", form, curEntry.getLocalPlace().getPlaceName()); - } else { - curEntry = entry; - } + curEntry = nextKeyFromDirectory(formID, place, lastEntry, payloadArg); } else { addParallelTrackingInfo(curEntry.getServiceName()); logger.debug("Added parallel tracking = {}", this.visitedPlaces); diff --git a/src/main/java/emissary/directory/DirectoryPlace.java b/src/main/java/emissary/directory/DirectoryPlace.java index 85485b71d9..1083b6b0a2 100755 --- a/src/main/java/emissary/directory/DirectoryPlace.java +++ b/src/main/java/emissary/directory/DirectoryPlace.java @@ -1041,6 +1041,13 @@ protected List nextKeys(final String dataID, final IBaseDataObje return Collections.emptyList(); } + // remove denied entries + currentList.removeIf(de -> de.getLocalPlace() != null && de.getLocalPlace().isDenied(payload.currentForm())); + + if (currentList.isEmpty()) { + logger.debug("nextKeys - no non-DENIED entries found here for {}", dataID); + return Collections.emptyList(); + } // The list we are building for return to the caller final List keyList = new ArrayList<>(); diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index f169387b68..b6ee134209 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -2,8 +2,9 @@ import emissary.admin.PlaceStarter; import emissary.directory.DirectoryEntry; +import emissary.directory.DirectoryPlace; +import emissary.directory.EmissaryNode; import emissary.place.IServiceProviderPlace; -import emissary.place.ServiceProviderPlace; import emissary.test.core.junit5.UnitTest; import org.junit.jupiter.api.AfterEach; @@ -82,40 +83,31 @@ void testAddParrallelTrackingInfo() { @Test void testDenyList() throws Exception { - byte[] configDeniedData = ("PLACE_NAME = \"DelayPlace\"\n" + "SERVICE_NAME = \"DELAY\"\n" - + "SERVICE_TYPE = \"STUDY\"\n" + "SERVICE_DESCRIPTION = \"delay stuff\"\n" + "SERVICE_COST = 99\n" - + "SERVICE_QUALITY = 50\n" + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"FINI\"\n").getBytes(); - InputStream config = new ByteArrayInputStream(configDeniedData); - IServiceProviderPlace place = new PlaceTest(config); HDMobileAgent agent = new MobAg2(); // test accepted + byte[] configDeniedData = ("PLACE_NAME = \"DelayPlace\"\n" + "SERVICE_NAME = \"DELAY\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_COST = 99\n" + "SERVICE_QUALITY = 50\n" + + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"FINI\"\n").getBytes(); + InputStream config = new ByteArrayInputStream(configDeniedData); + DirectoryPlace place = new PlaceTest("http://example.com:8001/DelayPlace", config); IBaseDataObject d1 = DataObjectFactory.getInstance(); d1.setCurrentForm("THECF"); - d1.appendTransformHistory("S.GARBAGE.ANALYZE.http://localhost:8005/GarbagePlace$1234"); agent.getNextKey(place, d1); // test denied + byte[] configDeniedData2 = ("PLACE_NAME = \"DelayPlace2\"\n" + "SERVICE_NAME = \"DELAY2\"\n" + + "SERVICE_TYPE = \"ANALYZE\"\n" + "SERVICE_COST = 99\n" + "SERVICE_QUALITY = 50\n" + + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"FINI\"\n").getBytes(); + InputStream config2 = new ByteArrayInputStream(configDeniedData2); + DirectoryPlace place2 = new PlaceTest("http://example.com:8002/DelayPlace", config2); IBaseDataObject d2 = DataObjectFactory.getInstance(); d2.setCurrentForm("FINI"); - d2.appendTransformHistory("A.FOO1.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d2); - - // test upstream in parallel tracking - byte[] configDeniedData2 = ("PLACE_NAME = \"FilePickUpClient\"\n" + "SERVICE_NAME = \"DELAY\"\n" - + "SERVICE_TYPE = \"STUDY\"\n" + "SERVICE_DESCRIPTION = \"delay stuff\"\n" + "SERVICE_COST = 99\n" - + "SERVICE_QUALITY = 50\n" + "SERVICE_PROXY = \"*\"\n" + "SERVICE_PROXY_DENY = \"THECF\"\n").getBytes(); - InputStream config2 = new ByteArrayInputStream(configDeniedData2); - PlaceStarter.createPlace("http://localhost:8005/FilePickUpClient", config2, - "emissary.pickup.file.FilePickUpClientTest$MyFilePickUpClient", null); - IBaseDataObject d3 = DataObjectFactory.getInstance(); - d3.setCurrentForm("THECF"); - d3.appendTransformHistory("B.FOO1.ANALYZE.http://localhost:8005/GarbagePlace$1234"); - agent.getNextKey(place, d3); + agent.getNextKey(place2, d2); // verify - assertEquals(1, agent.visitedPlaces.size(), "FOO2 and FOO3 should not have been added"); - assertTrue(agent.visitedPlaces.contains("FOO"), "Only FOO should have been added"); + assertEquals(1, agent.visitedPlaces.size(), "DELAY2 should not have been added"); + assertTrue(agent.visitedPlaces.contains("DELAY"), "Only DELAY should have been added"); agent.killAgent(); place.shutDown(); @@ -144,38 +136,11 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServic } } - static final class MobAg2 extends HDMobileAgent { - private boolean hit = false; - - @Override - protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServiceProviderPlace place, final DirectoryEntry lastEntry, - final IBaseDataObject payloadArg) { - if (lastEntry.getDataType().equalsIgnoreCase("S")) { - DirectoryEntry d = new DirectoryEntry("A.FOO.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); - d.isLocal(); - return d; - } else if (lastEntry.getDataType().equalsIgnoreCase("A")) { - DirectoryEntry d = new DirectoryEntry("B.FOO2.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); - d.isLocal(); - return d; - } else if (lastEntry.getDataType().equalsIgnoreCase("B")) { - DirectoryEntry d = new DirectoryEntry("C.FOO.ANALYZE.http://localhost:8001/PlaceTest$9950[1]"); - d.isLocal(); - return d; - } else if (!hit && lastEntry.getDataType().equalsIgnoreCase("THECF")) { - DirectoryEntry d = new DirectoryEntry("D.FOO3.ANALYZE.http://localhost:8005/FilePickUpClient"); - d.isLocal(); - hit = true; - return d; - } else { - return null; - } + class PlaceTest extends DirectoryPlace { + public PlaceTest(final String placeLoc, InputStream config) throws IOException { + super(config, placeLoc, new EmissaryNode()); } } - - private static final class PlaceTest extends ServiceProviderPlace { - public PlaceTest(InputStream config) throws IOException { - super(config); - } + static final class MobAg2 extends HDMobileAgent { } } From 012a715ec08c84cc9136925b8cd28cedd5abf58c Mon Sep 17 00:00:00 2001 From: aL118 Date: Wed, 2 Aug 2023 10:39:38 -0400 Subject: [PATCH 11/12] added tests in RoutingAlgorithmTest --- .../emissary/place/sample/DelayPlace.cfg | 12 +++--- .../directory/RoutingAlgorithmTest.java | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/main/resources/emissary/place/sample/DelayPlace.cfg b/src/main/resources/emissary/place/sample/DelayPlace.cfg index f0e5baef14..49e1b158e6 100644 --- a/src/main/resources/emissary/place/sample/DelayPlace.cfg +++ b/src/main/resources/emissary/place/sample/DelayPlace.cfg @@ -1,14 +1,12 @@ PLACE_NAME = "DelayPlace" SERVICE_NAME = "DELAY" -SERVICE_TYPE = "TRANSFORM" +SERVICE_TYPE = "ANALYZE" SERVICE_DESCRIPTION = "delay stuff" SERVICE_COST = 50 SERVICE_QUALITY = 50 -SERVICE_PROXY = "YOU_FORGOT_TO_SET_DELAYPLACE_SERVICE_PROXY" -SERVICE_PROXY = "FINI" +# Add Wildcard entry +SERVICE_PROXY = "*" +SERVICE_PROXY_DENY = "MYFORM" -#DELAY_TIME_MILLIS = 2000 -DELAY_TIME_MILLIS = 20000 - -PLACE_RESOURCE_LIMIT_MILLIS = "-1" +DELAY_TIME_MILLIS = 200 \ No newline at end of file diff --git a/src/test/java/emissary/directory/RoutingAlgorithmTest.java b/src/test/java/emissary/directory/RoutingAlgorithmTest.java index 0de2f9c821..a8d05927fc 100644 --- a/src/test/java/emissary/directory/RoutingAlgorithmTest.java +++ b/src/test/java/emissary/directory/RoutingAlgorithmTest.java @@ -5,6 +5,7 @@ import emissary.core.HDMobileAgent; import emissary.core.IBaseDataObject; import emissary.place.IServiceProviderPlace; +import emissary.place.sample.DelayPlace; import emissary.test.core.junit5.UnitTest; import emissary.util.io.ResourceReader; @@ -366,6 +367,46 @@ void testCompleteKeyRouting() { assertEquals(foo2.getKey(), result.getKey(), "Routing must take place to fully qualified key"); } + @Test + void testWildCardProxyHonorsDenyList() throws IOException { + loadAllTestEntries(); + + this.payload.pushCurrentForm("MYFORM"); + + // create our place and add it to the directory. This place proxies for "*" but explicitly denies "MYFORM" + DelayPlace deniedWildcardPlace = new DelayPlace(new ResourceReader().getConfigDataName(DelayPlace.class).replace("/main/", "/test/")); + this.dir.addTestEntry(deniedWildcardPlace.getDirectoryEntry()); + + // Add another entry that proxies for "MYFORM". + // Doesn't need an actual place, but does need a higher expense than deniedWildcardPlace + DirectoryEntry expected = new DirectoryEntry("MYFORM.s4.ANALYZE.http://example.com:8001/A$9999"); + this.dir.addTestEntry(expected); + + final DirectoryEntry result = this.agent.getNextKeyAccess(this.dir, this.payload); + assertEquals(expected, result, "After a denied entry, should get next matching entry for the same stage"); + } + + @Test + void testWildCardProxyWithDeniedEntry() throws IOException { + loadAllTestEntries(); + + this.payload.pushCurrentForm("OTHERFORM"); + + // create our place and add it to the directory. This place proxies for "*" but explicitly denies "MYFORM" + DelayPlace deniedWildcardPlace = new DelayPlace(new ResourceReader().getConfigDataName(DelayPlace.class).replace("/main/", "/test/")); + this.dir.addTestEntry(deniedWildcardPlace.getDirectoryEntry()); + + // OTHERFORM is not denied so we expect non-null result + final DirectoryEntry result = this.agent.getNextKeyAccess(this.dir, this.payload); + assertEquals(deniedWildcardPlace.getKey(), result.getKey(), "Should get matching entry for wildcard place"); + + this.payload.pushCurrentForm("MYFORM"); + + // MYFORM is denied so null should be returned + final DirectoryEntry nullResult = this.agent.getNextKeyAccess(this.dir, this.payload); + assertNull(nullResult, "MYFORM should be denied"); + } + /** * Extend directory place to allow us to access the entryMap */ From 52c937e57ccc842dd27628dc3c180f1b6358c782 Mon Sep 17 00:00:00 2001 From: aL118 Date: Wed, 23 Aug 2023 10:50:46 -0400 Subject: [PATCH 12/12] fixed inner classes --- src/test/java/emissary/core/MobileAgentTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/emissary/core/MobileAgentTest.java b/src/test/java/emissary/core/MobileAgentTest.java index b6ee134209..42c40b7e7d 100644 --- a/src/test/java/emissary/core/MobileAgentTest.java +++ b/src/test/java/emissary/core/MobileAgentTest.java @@ -83,7 +83,7 @@ void testAddParrallelTrackingInfo() { @Test void testDenyList() throws Exception { - HDMobileAgent agent = new MobAg2(); + HDMobileAgent agent = new HDMobileAgent(); // test accepted byte[] configDeniedData = ("PLACE_NAME = \"DelayPlace\"\n" + "SERVICE_NAME = \"DELAY\"\n" @@ -136,11 +136,9 @@ protected DirectoryEntry nextKeyFromDirectory(final String dataID, final IServic } } - class PlaceTest extends DirectoryPlace { + static class PlaceTest extends DirectoryPlace { public PlaceTest(final String placeLoc, InputStream config) throws IOException { super(config, placeLoc, new EmissaryNode()); } } - static final class MobAg2 extends HDMobileAgent { - } }