Commit f9697fb4 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Allowed JWT usage on all endpoints and refactoring

parent e3dd2142
Pipeline #582 passed with stages
in 31 seconds
spring.main.banner-mode=off
logging.level.root=OFF
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class AddMemberCall extends BaseCall<GmsClient> {
public boolean addMember(String completeGroupName, String userId) {
String endpoint = "membership";
String endpoint = "ws/jwt/membership";
if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName;
}
......
......@@ -16,7 +16,7 @@ public class AddPermissionCall extends BaseCall<GmsClient> {
public String addPermission(String completeGroupName, String userId, Permission permission) {
String endpoint = "permission";
String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName;
}
......
......@@ -14,7 +14,7 @@ public class CreateGroupCall extends BaseCall<GmsClient> {
public boolean createGroup(String completeGroupName, boolean leaf) {
HttpRequest groupsRequest = client.newRequest(completeGroupName)
HttpRequest groupsRequest = client.newRequest("ws/jwt/" + completeGroupName)
.header("Accept", "text/plain")
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(BodyPublishers.ofString("leaf=" + leaf))
......
......@@ -13,7 +13,7 @@ public class DeleteGroupCall extends BaseCall<GmsClient> {
public boolean deleteGroup(String completeGroupName) {
HttpRequest groupsRequest = client.newRequest(completeGroupName)
HttpRequest groupsRequest = client.newRequest("ws/jwt/" + completeGroupName)
.header("Accept", "text/plain")
.DELETE()
.build();
......
......@@ -20,7 +20,7 @@ public class GetGroupPermissionsCall extends BaseCall<GmsClient> {
List<GroupPermission> groupPermissions = new ArrayList<>();
String endpoint = "permission";
String endpoint = "ws/jwt/permission";
endpoint += "/" + groupId;
HttpRequest groupsRequest = client.newRequest(endpoint)
......
......@@ -22,7 +22,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>();
HttpRequest groupsRequest = client.newRequest("search")
HttpRequest groupsRequest = client.newRequest("vo/search")
.header("Accept", "text/plain")
.GET()
.build();
......@@ -52,7 +52,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>();
String endpoint = "membership";
String endpoint = "ws/jwt/membership";
if (prefix != null && !prefix.isBlank()) {
endpoint += "/" + prefix;
}
......
......@@ -20,7 +20,7 @@ public class GetUserPermissionsCall extends BaseCall<GmsClient> {
List<UserPermission> userPermissions = new ArrayList<>();
String endpoint = "permission";
String endpoint = "ws/jwt/permission";
endpoint += "?user_id=" + userId;
HttpRequest groupsRequest = client.newRequest(endpoint)
......
......@@ -23,7 +23,7 @@ public class ListGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>();
String uri = "list";
String uri = "ws/jwt/list";
if (prefix != null && !prefix.isBlank()) {
uri += "/" + prefix;
}
......
......@@ -13,7 +13,7 @@ public class RemoveMemberCall extends BaseCall<GmsClient> {
public boolean removeMember(String completeGroupName, String userId) {
String endpoint = "membership";
String endpoint = "ws/jwt/membership";
if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName;
}
......
......@@ -13,7 +13,7 @@ public class RemovePermissionCall extends BaseCall<GmsClient> {
public boolean removePermission(String completeGroupName, String userId) {
String endpoint = "permission";
String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName;
}
......
......@@ -14,7 +14,7 @@ public class SetPermissionCall extends BaseCall<GmsClient> {
public String setPermission(String completeGroupName, String userId, Permission permission) {
String endpoint = "permission";
String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName;
}
......
......@@ -28,6 +28,6 @@ public class AddMemberTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.addMember("LBT.INAF", "user");
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "membership/LBT.INAF"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "ws/jwt/membership/LBT.INAF"), any());
}
}
......@@ -29,6 +29,6 @@ public class AddPermissionTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.addPermission("LBT.INAF", "user", Permission.ADMIN);
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "permission/LBT.INAF"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "ws/jwt/permission/LBT.INAF"), any());
}
}
......@@ -28,6 +28,6 @@ public class CreateGroupTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.createGroup("LBT.INAF", false);
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "LBT.INAF"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("POST", "ws/jwt/LBT.INAF"), any());
}
}
......@@ -28,6 +28,6 @@ public class DeleteGroupTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.deleteGroup("LBT.INAF");
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "LBT.INAF"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "ws/jwt/LBT.INAF"), any());
}
}
......@@ -34,7 +34,7 @@ public class GetUserGroupsTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
List<String> groups = gmsClient.getMyGroups("LBT.");
verify(httpClient, times(1)).sendAsync(endpointEq("GET", "search"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("GET", "vo/search"), any());
assertEquals(2, groups.size());
assertEquals("INAF", groups.get(0));
......@@ -52,7 +52,7 @@ public class GetUserGroupsTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
List<String> groups = gmsClient.listGroups("LBT.");
verify(httpClient, times(1)).sendAsync(endpointEq("GET", "list/LBT."), any());
verify(httpClient, times(1)).sendAsync(endpointEq("GET", "ws/jwt/list/LBT."), any());
assertEquals(2, groups.size());
assertEquals("INAF", groups.get(0));
......
......@@ -28,6 +28,6 @@ public class RemoveMemberTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.removeMember("LBT.INAF", "user");
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "membership/LBT.INAF?user_id=user"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "ws/jwt/membership/LBT.INAF?user_id=user"), any());
}
}
......@@ -28,6 +28,6 @@ public class RemovePermissionTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.removePermission("LBT.INAF", "user");
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "permission/LBT.INAF?user_id=user"), any());
verify(httpClient, times(1)).sendAsync(endpointEq("DELETE", "ws/jwt/permission/LBT.INAF?user_id=user"), any());
}
}
......@@ -68,36 +68,46 @@
</dependency>
</dependencies>
<profiles>
<profile>
<id>build-gui</id>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<nodeVersion>v12.6.0</nodeVersion>
<environmentVariables>
<VUE_APP_SHOW_USER_ID_IN_SEARCH>${show.user_id_in_search}</VUE_APP_SHOW_USER_ID_IN_SEARCH>
</environmentVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build --prefix ../gms-ui</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>gms</finalName>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<nodeVersion>v12.6.0</nodeVersion>
<environmentVariables>
<VUE_APP_SHOW_USER_ID_IN_SEARCH>${show.user_id_in_search}</VUE_APP_SHOW_USER_ID_IN_SEARCH>
</environmentVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build --prefix ../gms-ui</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment