moved to new gcube-security

This commit is contained in:
lucio 2024-02-21 20:29:54 +01:00
parent f9f535d252
commit fba448a7f2
4 changed files with 12 additions and 14 deletions

View File

@ -47,7 +47,7 @@ public class ScopedServiceMap implements ServiceMap {
//helper //helper
public ServiceMap currentMap() { public ServiceMap currentMap() {
String currentScope = SecretManagerProvider.instance.get().getContext(); String currentScope = SecretManagerProvider.get().getContext();
if (currentScope==null) if (currentScope==null)
throw new IllegalStateException("current scope is undefined"); throw new IllegalStateException("current scope is undefined");

View File

@ -45,11 +45,9 @@ class ServiceMapScanner {
try { try {
Collection<URL> urls = ClasspathHelper.forClassLoader(); Collection<URL> urls = ClasspathHelper.forJavaClassPath();
urls.removeIf(url -> url.toString().endsWith(".so") || url.toString().endsWith(".zip") );
ConfigurationBuilder reflectionConf = new ConfigurationBuilder().addUrls(ClasspathHelper.forJavaClassPath()).addUrls(ClasspathHelper.forClassLoader()).setScanners(new ResourcesScanner());
ConfigurationBuilder reflectionConf = new ConfigurationBuilder().addUrls(urls).setScanners(new ResourcesScanner());
Reflections reflection = new Reflections(reflectionConf); Reflections reflection = new Reflections(reflectionConf);

View File

@ -21,12 +21,12 @@ public class BindingTest {
final String callScope = "somescope"; final String callScope = "somescope";
SecretManagerProvider.instance.set(new TestSecret(callScope)); SecretManagerProvider.set(new TestSecret(callScope));
Callable<Void> unbound = new Callable<Void>() { Callable<Void> unbound = new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
assertEquals("task thread is not bound to call scope, but to "+SecretManagerProvider.instance.get().getContext(),callScope,SecretManagerProvider.instance.get().getContext()); assertEquals("task thread is not bound to call scope, but to "+SecretManagerProvider.get().getContext(),callScope,SecretManagerProvider.get().getContext());
return null; return null;
} }
}; };
@ -36,21 +36,21 @@ public class BindingTest {
String newScope = "newscope"; String newScope = "newscope";
//scope in current thread changes //scope in current thread changes
SecretManagerProvider.instance.set(new TestSecret(newScope)); SecretManagerProvider.set(new TestSecret(newScope));
//task is submittted //task is submittted
executor.submit(bound).get(); executor.submit(bound).get();
//resetting task //resetting task
assertEquals("call thread does not retain its latest scope",newScope,SecretManagerProvider.instance.get().getContext()); assertEquals("call thread does not retain its latest scope",newScope,SecretManagerProvider.get().getContext());
//reset call scope //reset call scope
SecretManagerProvider.instance.reset(); SecretManagerProvider.reset();
Callable<Void> cleanupTest = new Callable<Void>() { Callable<Void> cleanupTest = new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
assertNull(SecretManagerProvider.instance.get()); assertNull(SecretManagerProvider.get());
return null; return null;
} }
}; };

View File

@ -54,7 +54,7 @@ public class ServiceMapTest {
@Test @Test
public void serviceMapsDiscoveredCorrectly() throws Exception { public void serviceMapsDiscoveredCorrectly() throws Exception {
SecretManagerProvider.instance.set(new TestSecret("/infra/vo")); SecretManagerProvider.set(new TestSecret("/infra/vo"));
assertNotNull(ServiceMap.instance.endpoint("service1")); assertNotNull(ServiceMap.instance.endpoint("service1"));
@ -65,7 +65,7 @@ public class ServiceMapTest {
@Test @Test
public void serviceMapsCanBeLookedupInVREScope() throws Exception { public void serviceMapsCanBeLookedupInVREScope() throws Exception {
SecretManagerProvider.instance.set(new TestSecret("/infra/vo/vre")); SecretManagerProvider.set(new TestSecret("/infra/vo/vre"));
assertNotNull(ServiceMap.instance.endpoint("service1")); assertNotNull(ServiceMap.instance.endpoint("service1"));
@ -73,7 +73,7 @@ public class ServiceMapTest {
@After @After
public void cleanup() { public void cleanup() {
SecretManagerProvider.instance.reset(); SecretManagerProvider.reset();
} }
} }