diff --git a/.classpath b/.classpath
index 5b0cf1c..33399d6 100644
--- a/.classpath
+++ b/.classpath
@@ -1,23 +1,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -35,5 +22,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 61fbcb3..6d9fc4f 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,6 +1,6 @@
-
+
diff --git a/pom.xml b/pom.xml
index c227b67..32cfe6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,12 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+
maven-parent
org.gcube.tools
1.1.0
+
org.gcube.common
oidc-library
1.1.0-SNAPSHOT
@@ -40,6 +42,12 @@
com.googlecode.json-simple
json-simple
+
+ junit
+ junit
+ 4.12
+ test
+
\ No newline at end of file
diff --git a/src/test/java/org/gcube/oidc/rest/RestHelperTest.java b/src/test/java/org/gcube/oidc/rest/RestHelperTest.java
index 99dc4f0..d0fdd9d 100644
--- a/src/test/java/org/gcube/oidc/rest/RestHelperTest.java
+++ b/src/test/java/org/gcube/oidc/rest/RestHelperTest.java
@@ -1,21 +1,33 @@
package org.gcube.oidc.rest;
+import static org.junit.Assert.assertNotNull;
+
import java.net.URL;
+import org.junit.Test;
+
public class RestHelperTest {
public RestHelperTest() {
}
- public static void main(String[] args) throws Exception {
- URL tokenURL = new URL("https://nubis2.int.d4science.net/auth/realms/d4science/protocol/openid-connect/token");
- JWTToken token = OpenIdConnectRESTHelper.queryClientToken("lr62_portal", "28726d01-9f24-4ef4-a057-3d208d96aaa0",
- tokenURL);
+ @Test
+ public void getAvatar() throws Exception {
+ String accessTokenBearer = "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmRE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F4eDc2QGdtYWlsLmNvbSJ9.WMddlUQujlpmzW07Lrk50vOyWpiT1Tp_RsBWRbzyrQnu5EQQSCq1uGOuSf7Z3VZFv8fbnzWekMZRNzhngEddzOQHgAlsgRdqNI_-ucjmb_8SfR2I5PkYJLTG0jF-Urqi-GvfJtLr2B8dBDnMDO6FLFsg1e5qb-5HkV60eEtY2Wult1PGxlkD05w-K2w513IOMkVIl25ZxKbP61-Iu1qfV_q3QFvUHl_pdqL7uKC5bkl1lqTVeuCwrXrKubHnKc-UzpHtHp8XY0Iao7LdLtON7SODYhU8EkZ860ZlFTSCszmLUpSH4t_shSk9Fiqd8wBKAet5ngmyAPzKx9TT2FK65g";
+ URL avatarURL = new URL("https://accounts.dev.d4science.org/auth/realms/d4science/avatar-provider/");
-// System.out.println(token.getExpAsDate());
- System.out.println(token.getAzp());
-// Thread.sleep((token.getExp() * 1000 - System.currentTimeMillis() + 5000));
-// System.out.println(token.isExpired());
+ byte[] avatarBytes = OpenIdConnectRESTHelper.getUserAvatar(avatarURL, accessTokenBearer);
+ assertNotNull(avatarBytes);
}
+// @Test
+ public void getExp() throws Exception {
+ URL tokenURL = new URL("https://nubis2.int.d4science.net/auth/realms/d4science/protocol/openid-connect/token");
+ JWTToken token = OpenIdConnectRESTHelper.queryClientToken("lr62_portal", "28726d01-9f24-4ef4-a057-3d208d96aaa0",
+ tokenURL);
+ System.out.println(token.getExpAsDate());
+ System.out.println(token.getAzp());
+ Thread.sleep((token.getExp() * 1000 - System.currentTimeMillis() + 5000));
+ System.out.println(token.isExpired());
+ }
}
diff --git a/src/test/resources/log4j.xml b/src/test/resources/log4j.xml
index 7a4fbee..be612ea 100644
--- a/src/test/resources/log4j.xml
+++ b/src/test/resources/log4j.xml
@@ -12,7 +12,7 @@
-
+