Skip to content

Commit

Permalink
add test to exercise change from unauth to forbidden #10340
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Dec 20, 2024
1 parent bc7cb23 commit caa00fb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import static jakarta.ws.rs.core.Response.Status.FORBIDDEN;
import java.util.logging.Logger;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -69,7 +70,15 @@ public void testCreateDeleteRoles() {
body = addBuiltinRoleResponse.getBody().asString();
status = JsonPath.from(body).getString("status");
assertEquals("OK", status);


Response createNoPermsUser = UtilIT.createRandomUser();
createNoPermsUser.prettyPrint();
String noPermsapiToken = UtilIT.getApiTokenFromResponse(createNoPermsUser);

Response noPermsResponse = UtilIT.viewDataverseRole("testRole", noPermsapiToken);
noPermsResponse.prettyPrint();
noPermsResponse.then().assertThat().statusCode(FORBIDDEN.getStatusCode());

Response viewDataverseRoleResponse = UtilIT.viewDataverseRole("testRole", apiToken);
viewDataverseRoleResponse.prettyPrint();
body = viewDataverseRoleResponse.getBody().asString();
Expand Down

0 comments on commit caa00fb

Please sign in to comment.