Skip to content

Commit

Permalink
fix(jans-auth-server): corrected npe in response type class
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Mar 23, 2022
1 parent e3d9dbf commit 941248d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.Lists;
import io.jans.orm.annotation.AttributeEnum;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -136,6 +137,9 @@ public static List<ResponseType> fromString(String paramList, String separator)
}

public static boolean isImplicitFlow(String responseTypes) {
if (StringUtils.isBlank(responseTypes)) {
return false;
}
return !responseTypes.contains("code") && (responseTypes.contains("id_token") || responseTypes.contains("token"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.jans.as.model.common;

import org.testng.Assert;
import org.testng.annotations.Test;

import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

/**
* @author Yuriy Zabrovarnyy
*/
public class ResponseTypeTest {


@Test
public void isImplicitFlow_withNull_shouldReturnFalseWithoutException() {
assertFalse(ResponseType.isImplicitFlow(null));
}

@Test
public void isImplicitFlow_withBlankValue_shouldReturnFalse() {
assertFalse(ResponseType.isImplicitFlow(""));
}

@Test
public void isImplicitFlow_withUnknownValue_shouldReturnFalse() {
assertFalse(ResponseType.isImplicitFlow("dfs"));
}

@Test
public void isImplicitFlow_withTokenAndIdTokenValue_shouldReturnTrue() {
assertTrue(ResponseType.isImplicitFlow("token id_token"));
}
}

0 comments on commit 941248d

Please sign in to comment.