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

Fixed http response status check in gms-client lib

parent 947c53e1
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ public class AddMemberCall extends BaseGmsCall { ...@@ -19,6 +19,7 @@ public class AddMemberCall extends BaseGmsCall {
HttpRequest groupsRequest = newHttpRequest(endpoint) HttpRequest groupsRequest = newHttpRequest(endpoint)
.header("Accept", "text/plain") .header("Accept", "text/plain")
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(BodyPublishers.ofString("user_id=" + userId)) .POST(BodyPublishers.ofString("user_id=" + userId))
.build(); .build();
......
...@@ -24,6 +24,7 @@ public class AddPermissionCall extends BaseGmsCall { ...@@ -24,6 +24,7 @@ public class AddPermissionCall extends BaseGmsCall {
HttpRequest groupsRequest = newHttpRequest(endpoint) HttpRequest groupsRequest = newHttpRequest(endpoint)
.header("Accept", "text/plain") .header("Accept", "text/plain")
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(requestBody) .POST(requestBody)
.build(); .build();
......
...@@ -19,7 +19,7 @@ public class CreateGroupCall extends BaseGmsCall { ...@@ -19,7 +19,7 @@ public class CreateGroupCall extends BaseGmsCall {
return getClient().sendAsync(groupsRequest, HttpResponse.BodyHandlers.ofInputStream()) return getClient().sendAsync(groupsRequest, HttpResponse.BodyHandlers.ofInputStream())
.thenApply(response -> { .thenApply(response -> {
if (response.statusCode() == 200) { if (response.statusCode() == 201) {
return true; return true;
} }
logServerErrorInputStream(groupsRequest, response); logServerErrorInputStream(groupsRequest, response);
......
...@@ -82,7 +82,7 @@ public class GmsClientTest { ...@@ -82,7 +82,7 @@ public class GmsClientTest {
@Test @Test
public void testCreateGroup() { public void testCreateGroup() {
CompletableFuture response = CompletableFuture.completedFuture(getMockedResponse(200)); CompletableFuture response = CompletableFuture.completedFuture(getMockedResponse(201));
when(httpClient.sendAsync(any(), any())).thenReturn(response); when(httpClient.sendAsync(any(), any())).thenReturn(response);
client.createGroup("LBT.INAF", false); client.createGroup("LBT.INAF", false);
......
...@@ -278,7 +278,7 @@ public class JWTWebServiceController { ...@@ -278,7 +278,7 @@ public class JWTWebServiceController {
for (int i = 0; i < index + 1; i++) { for (int i = 0; i < index + 1; i++) {
String groupName = groupNames.get(i); String groupName = groupNames.get(i);
group = groupsDAO.findGroupByParentAndName(parentPath, groupName) group = groupsDAO.findGroupByParentAndName(parentPath, groupName)
.orElseThrow(() -> new IllegalArgumentException("Unable to find group " + groupName)); .orElseThrow(() -> new BadRequestException("Unable to find group " + groupName));
parentPath = group.getPath(); parentPath = group.getPath();
} }
if (group == null) { if (group == null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment