minor fixes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@131353 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5d0fa734d5
commit
ff6df17384
|
@ -158,7 +158,7 @@ public interface CKanUtils {
|
|||
boolean isSysAdmin(String username, String apiKey);
|
||||
|
||||
/**
|
||||
* Check if this role is present for this user in that organization. If it is not present we need to add it with the given role.
|
||||
* Check if this role is present for this user in the organization. If he/she is not present we need to add it with the given role.
|
||||
* @param username
|
||||
* @param organizationName
|
||||
* @param correspondentRoleToCheck
|
||||
|
|
|
@ -13,7 +13,9 @@ import org.gcube.datacatalogue.ckanutillibrary.models.DatasetRelationships;
|
|||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.CheckedCkanClient;
|
||||
import eu.trentorise.opendata.jackan.model.CkanOrganization;
|
||||
import eu.trentorise.opendata.jackan.model.CkanUser;
|
||||
|
||||
public class TestCKanLib {
|
||||
|
||||
|
@ -169,9 +171,69 @@ public class TestCKanLib {
|
|||
String scopeToUse = new ApplicationProfileScopePerUrlReader().getScopePerUrl(url);
|
||||
logger.debug("Retrieved scope is " + scopeToUse);
|
||||
|
||||
ScopeProvider.instance.reset(); // the sysout should print null
|
||||
ScopeProvider.instance.reset(); // the following sysout should print null
|
||||
String url2 = "https://dev4.d4science.org/group/devvre/ckan";
|
||||
String scopeToUse2 = new ApplicationProfileScopePerUrlReader().getScopePerUrl(url2);
|
||||
logger.debug("Retrieved scope is " + scopeToUse2);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void createUsers() throws Exception{
|
||||
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE");
|
||||
CheckedCkanClient client = new CheckedCkanClient(instance.getCatalogueUrl(), instance.getApiKeyFromUsername("costantino_perciante"));
|
||||
CkanUser editorUser = new CkanUser("user_editor_devvre", "user_editor_devvre@test.it", "");
|
||||
client.createUser(editorUser);
|
||||
CkanUser adminUser = new CkanUser("user_admin_devvre", "user_admin_devvre@test.it", "");
|
||||
client.createUser(adminUser);
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void createAsEditor() throws Exception{
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE");
|
||||
boolean checkedEditor = instance.checkRole("user_editor_devvre", "devvre", RolesIntoOrganization.EDITOR);
|
||||
if(checkedEditor){
|
||||
logger.debug("Created editor in devvre? " + checkedEditor);
|
||||
}
|
||||
boolean checkedAdmin = instance.checkRole("user_admin_devvre", "devvre", RolesIntoOrganization.ADMIN);
|
||||
if(checkedAdmin){
|
||||
logger.debug("Created admin in devvre? " + checkedAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void editorCreateDataset() throws Exception{
|
||||
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE");
|
||||
instance.createCKanDataset(instance.getApiKeyFromUsername("user_editor_devvre"), "dataset_as_editor_devvre_private", "devvre", null, null, null, null, 1, null, null, null, null, null, false);
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void adminCreateDataset() throws Exception{
|
||||
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE");
|
||||
//instance.createCKanDataset(instance.getApiKeyFromUsername("user_admin_devvre"), "dataset_as_admin_devvre", "devvre", null, null, null, null, 1, null, null, null, null, null, false);
|
||||
instance.createCKanDataset(instance.getApiKeyFromUsername("user_admin_devvre"), "dataset_as_admin_devvre_private", "devvre", null, null, null, null, 1, null, null, null, null, null, false);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void adminChangeVisibility() throws Exception{
|
||||
|
||||
CKanUtilsImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE");
|
||||
//instance.createCKanDataset(instance.getApiKeyFromUsername("user_editor_devvre"), "dataset_as_editor_devvre", "devvre", null, null, null, null, 1, null, null, null, null, null, false);
|
||||
//instance.setDatasetPrivate(true, "3571cca5-b0ae-4dc6-b791-434a8e062ce5", "dataset_as_admin_devvre_public", instance.getApiKeyFromUsername("user_admin_devvre"));
|
||||
|
||||
instance.setDatasetPrivate(true, "3571cca5-b0ae-4dc6-b791-434a8e062ce5", "33bbdcb1-929f-441f-8718-a9e5134f517d", instance.getApiKeyFromUsername("user_editor_devvre"));
|
||||
|
||||
// CheckedCkanClient client = new CheckedCkanClient(instance.getCatalogueUrl(), instance.getApiKeyFromUsername("user_admin_devvre"));
|
||||
// CkanDataset dataset = client.getDataset("dataset_as_admin_devvre_private");
|
||||
// logger.debug("Current value for private: " + dataset.isPriv());
|
||||
// dataset.setPriv(!dataset.isPriv());
|
||||
// CkanDataset datasetUpd = client.updateDataset(dataset);
|
||||
// logger.debug("Private value is " + datasetUpd.isPriv());
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue