Improved tests

This commit is contained in:
luca.frosini 2023-07-14 11:01:14 +02:00
parent 47e6c38ce9
commit b8dfefd4d9
2 changed files with 12 additions and 14 deletions

View File

@ -14,7 +14,6 @@ import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.authorization.utils.secret.SecretUtility;
import org.gcube.common.keycloak.KeycloakClientFactory;
import org.gcube.common.keycloak.model.TokenResponse;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
@ -39,8 +38,7 @@ public class ContextTest {
protected static final Properties properties;
protected static final String CLIENT_ID_PROPERTY_KEY = "client_id";
protected static final String clientID;
protected static final String CLIENT_ID_PROPERTY_KEY = "clientId";
static {
GCUBE = "/gcube";
@ -56,9 +54,7 @@ public class ContextTest {
try {
// load the properties file
properties.load(input);
clientID = properties.getProperty(CLIENT_ID_PROPERTY_KEY);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -80,12 +76,14 @@ public class ContextTest {
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);
String root = context.substring(0, index == -1 ? context.length() : index);
String clientSecret = properties.getProperty(root);
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientID, clientSecret, context, null);
return tr;
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(context, clientId, clientSecret, context, null);
return tr;
}
public static Secret getSecretByContextName(String context) throws Exception {

View File

@ -50,7 +50,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void listFolders() throws Exception {
List<String> contexts = new ArrayList<>();
contexts.add(GCUBE);
// contexts.add(GCUBE);
// contexts.add(DEVSEC);
// contexts.add(DEVVRE);
// contexts.add(DEVNEXT);
@ -65,7 +65,7 @@ public class StorageHubManagementTest extends ContextTest {
// storageHubManagement.tree(root);
FolderContainer contextFolder = storageHubManagement.getContextFolder();
storageHubManagement.tree(contextFolder);
// storageHubManagement.tree(contextFolder);
ListResolverTyped listResolverTyped = contextFolder.list();
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) {
logger.info("Catalogue folder found");
storageHubManagement.tree((FolderContainer) itemContainer);
/*
* // itemContainer.delete();
*/
// if(false) {
// itemContainer.delete();
// }
}else {
storageHubManagement.logItem(itemContainer);
// storageHubManagement.tree((FolderContainer) itemContainer);