Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Introspection Claims Test #2404

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class Claims {
private Long previousLogonTime;
@JsonProperty(ClaimConstants.AMR)
private String[] amr;
@JsonProperty(ClaimConstants.CLIENT_AUTH_METHOD)
private String clientAuth;

public String getUserId() {
return userId;
Expand Down Expand Up @@ -353,4 +355,12 @@ public List<String> getGrantedScopes() {
public void setGrantedScopes(List<String> grantedScopes) {
this.grantedScopes = grantedScopes;
}

public String getClientAuth() {
return this.clientAuth;
}

public void setClientAuth(final String clientAuth) {
this.clientAuth = clientAuth;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static public List<String> getStringValues() {
public static final String GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code";
public static final String GRANT_TYPE_IMPLICIT = "implicit";

public static final String CLIENT_AUTH_NONE = "none";

public static final String ID_TOKEN_HINT_PROMPT = "prompt";
public static final String ID_TOKEN_HINT_PROMPT_NONE = "none";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.cloudfoundry.identity.uaa.oauth.token;

import com.nimbusds.jose.util.Base64URL;
import org.cloudfoundry.identity.uaa.util.JsonUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.text.ParseException;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class IntrospectionClaimsTest {

private final static String TOKEN_PAYLOAD = "eyJqdGkiOiJiODc5MzNkYmQ3MDM0ZTZjODE1MDZmOTljODUwYWUwYSIsImNsaWVudF9hdXRoX21ldGhvZCI6Im5vbmUiLCJzdWIiOiJiZjNkOTJhNC1jNGVjLTQxMDQtOGJmNS0yZTMwMTFmZDQxODUiLCJzY29wZSI6WyJvcGVuaWQiXSwiY2xpZW50X2lkIjoibG9naW4iLCJjaWQiOiJsb2dpbiIsImF6cCI6ImxvZ2luIiwicmV2b2NhYmxlIjp0cnVlLCJncmFudF90eXBlIjoiYXV0aG9yaXphdGlvbl9jb2RlIiwidXNlcl9pZCI6ImJmM2Q5MmE0LWM0ZWMtNDEwNC04YmY1LTJlMzAxMWZkNDE4NSIsIm9yaWdpbiI6Imlhcy5wcm94eSIsInVzZXJfbmFtZSI6IkZpcnN0Lk5hbWVAZW1haWwub3JnIiwiZW1haWwiOiJGaXJzdC5OYW1lQGVtYWlsLm9yZyIsImF1dGhfdGltZSI6MTY4OTE3ODg2MiwicmV2X3NpZyI6IjIzYmRhYmZkIiwiaWF0IjoxNjg5MTc4ODYzLCJleHAiOjE2ODkyMjIwNjMsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC91YWEvb2F1dGgvdG9rZW4iLCJ6aWQiOiJ1YWEiLCJhdWQiOlsib3BlbmlkIiwibG9naW4iXX0";
private IntrospectionClaims INTROSPECTION_PAYLOAD;

@BeforeEach
void setup() throws ParseException {
String json = new Base64URL(TOKEN_PAYLOAD).decodeToString();
INTROSPECTION_PAYLOAD = JsonUtils.readValue(json, IntrospectionClaims.class);
INTROSPECTION_PAYLOAD.setActive(false);
}

@Test
void setActive() {
INTROSPECTION_PAYLOAD.setActive(true);
assertTrue(INTROSPECTION_PAYLOAD.isActive());
}

@Test
void isActive() {
assertFalse(INTROSPECTION_PAYLOAD.isActive());
}

@Test
void testSerialize() {
assertTrue(JsonUtils.writeValueAsString(INTROSPECTION_PAYLOAD).contains(TokenConstants.CLIENT_AUTH_NONE));
}
}