Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Feb 15, 2024
1 parent 5a89ae2 commit 5c85749
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,54 @@ public void testReadGrantsAsShibUser() throws IOException {
check(response, 200);
}

@Test
public void testReadGrantsAsShibUser_HeaderRequiredEveryRequest() throws IOException {
String url = getBaseUrl() + "data/grant";

Request.Builder builder = new Request.Builder();
setShibHeaders(builder);
Request request = builder.url(url).header("Accept", JSON_API_CONTENT_TYPE)
.addHeader("Content-Type", JSON_API_CONTENT_TYPE).get().build();

Response response = client.newCall(request).execute();

check(response, 200);

// no shib headers
builder = new Request.Builder();
Request request2 = builder.url(url).header("Accept", JSON_API_CONTENT_TYPE)
.addHeader("Content-Type", JSON_API_CONTENT_TYPE).get().build();

Response response2 = client.newCall(request2).execute();

check(response2, 401);
}

@Test
public void testReadGrantsAsShibUser_HeadersAuthEveryRequest() throws IOException {
String url = getBaseUrl() + "data/grant";

Request.Builder builder = new Request.Builder();
setShibHeaders(builder);
Request request = builder.url(url).header("Accept", JSON_API_CONTENT_TYPE)
.addHeader("Content-Type", JSON_API_CONTENT_TYPE).get().build();

Response response = client.newCall(request).execute();

check(response, 200);

// invalid eppn header shib headers
Request.Builder builder2 = new Request.Builder();
setShibHeaders(builder2);
builder2.header(ShibConstants.EPPN_HEADER, "badeppnheadervalue");
Request request2 = builder2.url(url).header("Accept", JSON_API_CONTENT_TYPE)
.addHeader("Content-Type", JSON_API_CONTENT_TYPE).get().build();

Response response2 = client.newCall(request2).execute();

check(response2, 400);
}

@Test
public void testCreateGrantAsShibUser() throws IOException, JSONException {

Expand Down

0 comments on commit 5c85749

Please sign in to comment.