Fixed Test

This commit is contained in:
Luca Frosini 2022-03-24 14:27:09 +01:00
parent 66fd1afc7c
commit 781729ff6d
1 changed files with 9 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import java.util.Set;
import org.gcube.common.authorization.utils.ContextTest;
import org.gcube.common.authorization.utils.secret.JWTSecret;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.authorization.utils.user.User;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,11 +27,13 @@ public class SecretManagerTest extends ContextTest {
}
}
@Test
public void testApptoken() throws Exception {
Secret secret = new JWTSecret("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDgwNDU2NjMsImlhdCI6MTY0ODA0NTM2MywianRpIjoiZTRmZDgyMmUtY2E3MS00MDA5LTkxYjctZTg4NzgyNGEzZDM3IiwiaXNzIjoiaHR0cHM6Ly9hY2NvdW50cy5kZXYuZDRzY2llbmNlLm9yZy9hdXRoL3JlYWxtcy9kNHNjaWVuY2UiLCJhdWQiOiIlMkZnY3ViZSUyRmRldnNlYyUyRmRldlZSRSIsInN1YiI6ImE5YTJhZTBiLTY5YzktNDFiNy05ZTRhLThhNGIyMmFhNWRkZSIsInR5cCI6IkJlYXJlciIsImF6cCI6IkJsdWUtQ2xvdWQtRU9TQy1vbmJvYXJkaW5nIiwic2Vzc2lvbl9zdGF0ZSI6IjBlYjkyMGU1LWViYzItNDdjYS05NGMzLTFjNjI0MTYzNjUyNiIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVzb3VyY2VfYWNjZXNzIjp7IiUyRmdjdWJlJTJGZGV2c2VjJTJGZGV2VlJFIjp7InJvbGVzIjpbIkNhdGFsb2d1ZS1FZGl0b3IiLCJNZW1iZXIiXX19LCJhdXRob3JpemF0aW9uI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y9kNHNjaWVuY2UiLCJhdWQiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsInN1YiI6ImE5YTJhZTBiLTY5YzktNDFiNy05ZTRhLThhNGIyMmFhNWRkZSIsInR5cCI6IlJlZnJlc2giLCJhenAiOiJCbHVlLUNsb3VkLUVPU0Mtb25ib2FyZGluZyIsInNlc3Npb25fc3RhdGUiOiIwZWI5MjBlNS1lYmMyLTQ3Y2EtOTRjMy0xYzYyNDE2MzY1MjYiLCJhdXRob3JpemF0aW9uIjp7InBlcm1pc3Npb25zIjpbeyJyc2lkIjoiNTcyODU1MTAtMzkzOS00ZGU3LThmYzEtZTNhOWQzY2NlMjgxIiwicnNuYW1lIjoiRGVmYXVsdCBSZXNvdXJjZSJ9XX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSJ9.t1yYIMzxrUC2UeiVxZ-LATSP-tYT2RsOD2");
String username = secret.getUsername();
String anotherUsername = secret.getUser().getUsername();
logger.debug("{} - {}", username, anotherUsername);
// @Test
public void testJWToken() throws Exception {
Secret secret = new JWTSecret("");
User user = secret.getUser();
String username = user.getUsername();
String surnameName = user.getFullName();
String nameSurname = user.getFullName(true);
logger.debug("{} - {} - {}", username, surnameName, nameSurname);
}
}