Fixing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@174603 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0b90790929
commit
e4f571a3bc
6
pom.xml
6
pom.xml
|
@ -103,12 +103,6 @@
|
|||
|
||||
<!-- END Document Store Lib -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>context-creation</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Accounting Libraries -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
|
|
|
@ -2,7 +2,14 @@ package org.gcube.authorization;
|
|||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||
import org.gcube.common.authorization.library.provider.ContainerInfo;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -15,8 +22,20 @@ public class ContextAuthorizationTest extends ContextTest {
|
|||
private static Logger logger = LoggerFactory.getLogger(ContextAuthorizationTest.class);
|
||||
|
||||
@Test
|
||||
public void generateTokenForExternalService() throws Exception {
|
||||
String applicationName = "";
|
||||
public void getInfo() throws Exception {
|
||||
ContextTest.setContext("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateApplicationToken() throws Exception {
|
||||
ContextTest.setContext(ROOT);
|
||||
|
||||
String context = "/d4science.research-infrastructures.eu/D4Research/AGINFRAplusDev";
|
||||
UserInfo userInfo = new UserInfo("luca.frosini",new ArrayList<>());
|
||||
String userToken = authorizationService().generateUserToken(userInfo, context);
|
||||
SecurityTokenProvider.instance.set(userToken);
|
||||
|
||||
String applicationName = "ScienceCatalogue";
|
||||
String generatedToken = authorizationService().generateExternalServiceToken(applicationName);
|
||||
|
||||
logger.trace("Application Token for application {} in Context {} is {}", applicationName,
|
||||
|
@ -25,7 +44,7 @@ public class ContextAuthorizationTest extends ContextTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void generateTokenForHost() throws Exception {
|
||||
public void generateHostToken() throws Exception {
|
||||
String currentContext = ContextUtility.getCurrentContext();
|
||||
String host = "pc-frosini.isti.cnr.it";
|
||||
int port = 8080;
|
||||
|
@ -36,4 +55,14 @@ public class ContextAuthorizationTest extends ContextTest {
|
|||
logger.trace("Token for Context {} for host {}:{} is {}", currentContext, host, port, tokenNode);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateUserToken() throws Exception {
|
||||
String currentContext = ContextUtility.getCurrentContext();
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(SecurityTokenProvider.instance.get());
|
||||
UserInfo userInfo = (UserInfo) authorizationEntry.getClientInfo();
|
||||
String tokenNode = authorizationService().generateUserToken(userInfo, currentContext);
|
||||
logger.trace("Token for Context {} for {} is {}", currentContext, userInfo.getId(), tokenNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue