@Test public void testGetCurrentUserReturnsCurrentUserId() { final UserId userId = TestHelpers.generateUserId(); final SecurityContext securityContext = new SecurityContext() { @Override public Principal getUserPrincipal() { return new Principal() { @Override public String getName() { return userId.toString(); } }; } @Override public boolean isUserInRole(String s) { return false; } @Override public boolean isSecure() { return false; } @Override public String getAuthenticationScheme() { return null; } }; final UserResource userResource = new UserResource(); final APIUserDetails APIUserDetails = userResource.fetchCurrentUserDetails(securityContext); assertThat(APIUserDetails.getId()).isEqualTo(userId); }
@GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") public APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context) { return new APIUserDetails(new UserId(context.getUserPrincipal().getName())); }
UserResource { @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") public APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context) { return new APIUserDetails(new UserId(context.getUserPrincipal().getName())); } }
UserResource { @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") public APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context) { return new APIUserDetails(new UserId(context.getUserPrincipal().getName())); }  }
UserResource { @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") public APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context) { return new APIUserDetails(new UserId(context.getUserPrincipal().getName())); }  @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context); }
UserResource { @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") public APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context) { return new APIUserDetails(new UserId(context.getUserPrincipal().getName())); }  @GET @Path("current") @PermitAll @Operation( summary = "Get the current user", description = "Returns the current user that Jobson believes is calling the API. This entrypoint *always* returns " + "*something*. If authentication is disabled (e.g. guest auth is enabled) then the client's ID is" + " handled as the guest username (usually, 'guest'). All other auth types have an associated username " + "that jobson will extract and return via this entrypoint") APIUserDetails fetchCurrentUserDetails(@Context SecurityContext context);  }