Skip to content
Snippets Groups Projects
Commit f9697fb4 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Allowed JWT usage on all endpoints and refactoring

parent e3dd2142
No related branches found
No related tags found
No related merge requests found
Pipeline #582 passed
Showing
with 57 additions and 49 deletions
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> { ...@@ -14,7 +14,7 @@ public class AddMemberCall extends BaseCall<GmsClient> {
public boolean addMember(String completeGroupName, String userId) { public boolean addMember(String completeGroupName, String userId) {
String endpoint = "membership"; String endpoint = "ws/jwt/membership";
if (completeGroupName != null && !completeGroupName.isBlank()) { if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName; endpoint += "/" + completeGroupName;
} }
......
...@@ -16,7 +16,7 @@ public class AddPermissionCall extends BaseCall<GmsClient> { ...@@ -16,7 +16,7 @@ public class AddPermissionCall extends BaseCall<GmsClient> {
public String addPermission(String completeGroupName, String userId, Permission permission) { public String addPermission(String completeGroupName, String userId, Permission permission) {
String endpoint = "permission"; String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) { if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName; endpoint += "/" + completeGroupName;
} }
......
...@@ -14,7 +14,7 @@ public class CreateGroupCall extends BaseCall<GmsClient> { ...@@ -14,7 +14,7 @@ public class CreateGroupCall extends BaseCall<GmsClient> {
public boolean createGroup(String completeGroupName, boolean leaf) { public boolean createGroup(String completeGroupName, boolean leaf) {
HttpRequest groupsRequest = client.newRequest(completeGroupName) HttpRequest groupsRequest = client.newRequest("ws/jwt/" + completeGroupName)
.header("Accept", "text/plain") .header("Accept", "text/plain")
.header("Content-Type", "application/x-www-form-urlencoded") .header("Content-Type", "application/x-www-form-urlencoded")
.POST(BodyPublishers.ofString("leaf=" + leaf)) .POST(BodyPublishers.ofString("leaf=" + leaf))
......
...@@ -13,7 +13,7 @@ public class DeleteGroupCall extends BaseCall<GmsClient> { ...@@ -13,7 +13,7 @@ public class DeleteGroupCall extends BaseCall<GmsClient> {
public boolean deleteGroup(String completeGroupName) { public boolean deleteGroup(String completeGroupName) {
HttpRequest groupsRequest = client.newRequest(completeGroupName) HttpRequest groupsRequest = client.newRequest("ws/jwt/" + completeGroupName)
.header("Accept", "text/plain") .header("Accept", "text/plain")
.DELETE() .DELETE()
.build(); .build();
......
...@@ -20,7 +20,7 @@ public class GetGroupPermissionsCall extends BaseCall<GmsClient> { ...@@ -20,7 +20,7 @@ public class GetGroupPermissionsCall extends BaseCall<GmsClient> {
List<GroupPermission> groupPermissions = new ArrayList<>(); List<GroupPermission> groupPermissions = new ArrayList<>();
String endpoint = "permission"; String endpoint = "ws/jwt/permission";
endpoint += "/" + groupId; endpoint += "/" + groupId;
HttpRequest groupsRequest = client.newRequest(endpoint) HttpRequest groupsRequest = client.newRequest(endpoint)
......
...@@ -22,7 +22,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> { ...@@ -22,7 +22,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>(); List<String> groups = new ArrayList<>();
HttpRequest groupsRequest = client.newRequest("search") HttpRequest groupsRequest = client.newRequest("vo/search")
.header("Accept", "text/plain") .header("Accept", "text/plain")
.GET() .GET()
.build(); .build();
...@@ -52,7 +52,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> { ...@@ -52,7 +52,7 @@ public class GetUserGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>(); List<String> groups = new ArrayList<>();
String endpoint = "membership"; String endpoint = "ws/jwt/membership";
if (prefix != null && !prefix.isBlank()) { if (prefix != null && !prefix.isBlank()) {
endpoint += "/" + prefix; endpoint += "/" + prefix;
} }
......
...@@ -20,7 +20,7 @@ public class GetUserPermissionsCall extends BaseCall<GmsClient> { ...@@ -20,7 +20,7 @@ public class GetUserPermissionsCall extends BaseCall<GmsClient> {
List<UserPermission> userPermissions = new ArrayList<>(); List<UserPermission> userPermissions = new ArrayList<>();
String endpoint = "permission"; String endpoint = "ws/jwt/permission";
endpoint += "?user_id=" + userId; endpoint += "?user_id=" + userId;
HttpRequest groupsRequest = client.newRequest(endpoint) HttpRequest groupsRequest = client.newRequest(endpoint)
......
...@@ -23,7 +23,7 @@ public class ListGroupsCall extends BaseCall<GmsClient> { ...@@ -23,7 +23,7 @@ public class ListGroupsCall extends BaseCall<GmsClient> {
List<String> groups = new ArrayList<>(); List<String> groups = new ArrayList<>();
String uri = "list"; String uri = "ws/jwt/list";
if (prefix != null && !prefix.isBlank()) { if (prefix != null && !prefix.isBlank()) {
uri += "/" + prefix; uri += "/" + prefix;
} }
......
...@@ -13,7 +13,7 @@ public class RemoveMemberCall extends BaseCall<GmsClient> { ...@@ -13,7 +13,7 @@ public class RemoveMemberCall extends BaseCall<GmsClient> {
public boolean removeMember(String completeGroupName, String userId) { public boolean removeMember(String completeGroupName, String userId) {
String endpoint = "membership"; String endpoint = "ws/jwt/membership";
if (completeGroupName != null && !completeGroupName.isBlank()) { if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName; endpoint += "/" + completeGroupName;
} }
......
...@@ -13,7 +13,7 @@ public class RemovePermissionCall extends BaseCall<GmsClient> { ...@@ -13,7 +13,7 @@ public class RemovePermissionCall extends BaseCall<GmsClient> {
public boolean removePermission(String completeGroupName, String userId) { public boolean removePermission(String completeGroupName, String userId) {
String endpoint = "permission"; String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) { if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName; endpoint += "/" + completeGroupName;
} }
......
...@@ -14,7 +14,7 @@ public class SetPermissionCall extends BaseCall<GmsClient> { ...@@ -14,7 +14,7 @@ public class SetPermissionCall extends BaseCall<GmsClient> {
public String setPermission(String completeGroupName, String userId, Permission permission) { public String setPermission(String completeGroupName, String userId, Permission permission) {
String endpoint = "permission"; String endpoint = "ws/jwt/permission";
if (completeGroupName != null && !completeGroupName.isBlank()) { if (completeGroupName != null && !completeGroupName.isBlank()) {
endpoint += "/" + completeGroupName; endpoint += "/" + completeGroupName;
} }
......
...@@ -28,6 +28,6 @@ public class AddMemberTest extends BaseGmsClientTest { ...@@ -28,6 +28,6 @@ public class AddMemberTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.addMember("LBT.INAF", "user"); 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 { ...@@ -29,6 +29,6 @@ public class AddPermissionTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.addPermission("LBT.INAF", "user", Permission.ADMIN); 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 { ...@@ -28,6 +28,6 @@ public class CreateGroupTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.createGroup("LBT.INAF", false); 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 { ...@@ -28,6 +28,6 @@ public class DeleteGroupTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.deleteGroup("LBT.INAF"); 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 { ...@@ -34,7 +34,7 @@ public class GetUserGroupsTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
List<String> groups = gmsClient.getMyGroups("LBT."); 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(2, groups.size());
assertEquals("INAF", groups.get(0)); assertEquals("INAF", groups.get(0));
...@@ -52,7 +52,7 @@ public class GetUserGroupsTest extends BaseGmsClientTest { ...@@ -52,7 +52,7 @@ public class GetUserGroupsTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
List<String> groups = gmsClient.listGroups("LBT."); 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(2, groups.size());
assertEquals("INAF", groups.get(0)); assertEquals("INAF", groups.get(0));
......
...@@ -28,6 +28,6 @@ public class RemoveMemberTest extends BaseGmsClientTest { ...@@ -28,6 +28,6 @@ public class RemoveMemberTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.removeMember("LBT.INAF", "user"); 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 { ...@@ -28,6 +28,6 @@ public class RemovePermissionTest extends BaseGmsClientTest {
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
gmsClient.removePermission("LBT.INAF", "user"); 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,8 +68,10 @@ ...@@ -68,8 +68,10 @@
</dependency> </dependency>
</dependencies> </dependencies>
<profiles>
<profile>
<id>build-gui</id>
<build> <build>
<finalName>gms</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>com.github.eirslett</groupId> <groupId>com.github.eirslett</groupId>
...@@ -98,6 +100,14 @@ ...@@ -98,6 +100,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>gms</finalName>
<plugins>
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment