Skip to content

Commit

Permalink
Move TestResource
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-walkiewicz authored and kokosing committed Jan 24, 2022
1 parent b31432c commit aed9ce6
Showing 1 changed file with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,29 +305,6 @@ public void testPasswordAuthenticatorUserMapping()
}
}

@javax.ws.rs.Path("/identity")
public static class TestResource
{
private final HttpRequestSessionContextFactory sessionContextFactory;

@Inject
public TestResource(AccessControl accessControl)
{
this.sessionContextFactory = new HttpRequestSessionContextFactory(createTestMetadataManager(), ImmutableSet::of, accessControl);
}

@ResourceSecurity(AUTHENTICATED_USER)
@GET
public javax.ws.rs.core.Response echoToken(@Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders)
{
Identity identity = sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, Optional.empty());
return javax.ws.rs.core.Response.ok()
.header("user", identity.getUser())
.header("principal", identity.getPrincipal().map(Principal::getName).orElse(null))
.build();
}
}

@Test
public void testPasswordAuthenticatorWithInsecureHttp()
throws Exception
Expand Down Expand Up @@ -744,6 +721,29 @@ private static String getOauthToken(OkHttpClient client, String url)
}
}

@javax.ws.rs.Path("/identity")
public static class TestResource
{
private final HttpRequestSessionContextFactory sessionContextFactory;

@Inject
public TestResource(AccessControl accessControl)
{
this.sessionContextFactory = new HttpRequestSessionContextFactory(createTestMetadataManager(), ImmutableSet::of, accessControl);
}

@ResourceSecurity(AUTHENTICATED_USER)
@GET
public javax.ws.rs.core.Response echoToken(@Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders)
{
Identity identity = sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, Optional.empty());
return javax.ws.rs.core.Response.ok()
.header("user", identity.getUser())
.header("principal", identity.getPrincipal().map(Principal::getName).orElse(null))
.build();
}
}

private void assertInsecureAuthentication(URI baseUri)
throws IOException
{
Expand Down

0 comments on commit aed9ce6

Please sign in to comment.