Improved tests
This commit is contained in:
parent
47e6c38ce9
commit
b8dfefd4d9
|
@ -14,7 +14,6 @@ import org.gcube.common.authorization.utils.secret.Secret;
|
||||||
import org.gcube.common.authorization.utils.secret.SecretUtility;
|
import org.gcube.common.authorization.utils.secret.SecretUtility;
|
||||||
import org.gcube.common.keycloak.KeycloakClientFactory;
|
import org.gcube.common.keycloak.KeycloakClientFactory;
|
||||||
import org.gcube.common.keycloak.model.TokenResponse;
|
import org.gcube.common.keycloak.model.TokenResponse;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -39,8 +38,7 @@ public class ContextTest {
|
||||||
|
|
||||||
protected static final Properties properties;
|
protected static final Properties properties;
|
||||||
|
|
||||||
protected static final String CLIENT_ID_PROPERTY_KEY = "client_id";
|
protected static final String CLIENT_ID_PROPERTY_KEY = "clientId";
|
||||||
protected static final String clientID;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
GCUBE = "/gcube";
|
GCUBE = "/gcube";
|
||||||
|
@ -57,8 +55,6 @@ public class ContextTest {
|
||||||
// load the properties file
|
// load the properties file
|
||||||
properties.load(input);
|
properties.load(input);
|
||||||
|
|
||||||
clientID = properties.getProperty(CLIENT_ID_PROPERTY_KEY);
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -80,11 +76,13 @@ public class ContextTest {
|
||||||
|
|
||||||
|
|
||||||
private static TokenResponse getJWTAccessToken(String context) throws Exception {
|
private static TokenResponse getJWTAccessToken(String context) throws Exception {
|
||||||
ScopeProvider.instance.set(context);
|
String clientId = properties.getProperty(CLIENT_ID_PROPERTY_KEY);
|
||||||
|
|
||||||
int index = context.indexOf('/', 1);
|
int index = context.indexOf('/', 1);
|
||||||
String root = context.substring(0, index == -1 ? context.length() : index);
|
String root = context.substring(0, index == -1 ? context.length() : index);
|
||||||
String clientSecret = properties.getProperty(root);
|
String clientSecret = properties.getProperty(root);
|
||||||
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientID, clientSecret, context, null);
|
|
||||||
|
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(context, clientId, clientSecret, context, null);
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class StorageHubManagementTest extends ContextTest {
|
||||||
@Test
|
@Test
|
||||||
public void listFolders() throws Exception {
|
public void listFolders() throws Exception {
|
||||||
List<String> contexts = new ArrayList<>();
|
List<String> contexts = new ArrayList<>();
|
||||||
contexts.add(GCUBE);
|
// contexts.add(GCUBE);
|
||||||
// contexts.add(DEVSEC);
|
// contexts.add(DEVSEC);
|
||||||
// contexts.add(DEVVRE);
|
// contexts.add(DEVVRE);
|
||||||
// contexts.add(DEVNEXT);
|
// contexts.add(DEVNEXT);
|
||||||
|
@ -65,7 +65,7 @@ public class StorageHubManagementTest extends ContextTest {
|
||||||
// storageHubManagement.tree(root);
|
// storageHubManagement.tree(root);
|
||||||
|
|
||||||
FolderContainer contextFolder = storageHubManagement.getContextFolder();
|
FolderContainer contextFolder = storageHubManagement.getContextFolder();
|
||||||
storageHubManagement.tree(contextFolder);
|
// storageHubManagement.tree(contextFolder);
|
||||||
|
|
||||||
ListResolverTyped listResolverTyped = contextFolder.list();
|
ListResolverTyped listResolverTyped = contextFolder.list();
|
||||||
List<ItemContainer<? extends Item>> containers = listResolverTyped.includeHidden().getContainers();
|
List<ItemContainer<? extends Item>> containers = listResolverTyped.includeHidden().getContainers();
|
||||||
|
@ -77,9 +77,9 @@ public class StorageHubManagementTest extends ContextTest {
|
||||||
if(name.compareTo(".catalogue")==0 || name.compareTo("service-account-gcat")==0 || name.compareTo("service-account-grsf-publisher")==0) {
|
if(name.compareTo(".catalogue")==0 || name.compareTo("service-account-gcat")==0 || name.compareTo("service-account-grsf-publisher")==0) {
|
||||||
logger.info("Catalogue folder found");
|
logger.info("Catalogue folder found");
|
||||||
storageHubManagement.tree((FolderContainer) itemContainer);
|
storageHubManagement.tree((FolderContainer) itemContainer);
|
||||||
/*
|
// if(false) {
|
||||||
* // itemContainer.delete();
|
// itemContainer.delete();
|
||||||
*/
|
// }
|
||||||
}else {
|
}else {
|
||||||
storageHubManagement.logItem(itemContainer);
|
storageHubManagement.logItem(itemContainer);
|
||||||
// storageHubManagement.tree((FolderContainer) itemContainer);
|
// storageHubManagement.tree((FolderContainer) itemContainer);
|
||||||
|
|
Loading…
Reference in New Issue