-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): reject par without pkce for fapi
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
jans-auth-server/server/src/test/java/io/jans/as/server/par/ws/rs/ParValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.jans.as.server.par.ws.rs; | ||
|
||
import io.jans.as.model.configuration.AppConfiguration; | ||
import io.jans.as.model.error.ErrorResponseFactory; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.ws.rs.WebApplicationException; | ||
|
||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* @author Yuriy Zabrovarnyy | ||
*/ | ||
@Listeners(MockitoTestNGListener.class) | ||
public class ParValidatorTest { | ||
|
||
@InjectMocks | ||
private ParValidator parValidator; | ||
|
||
@Mock | ||
private AppConfiguration appConfiguration; | ||
|
||
@Mock | ||
private ErrorResponseFactory errorResponseFactory; // mock is required | ||
|
||
@SuppressWarnings("java:S5976") // we do want separate methods with clear names. Clarity of use case. | ||
@Test | ||
public void validatePkce_whenFapiIsFalse_shouldNotThrowError() { | ||
when(appConfiguration.isFapi()).thenReturn(false); | ||
|
||
parValidator.validatePkce(null, null); | ||
} | ||
|
||
@Test(expectedExceptions = WebApplicationException.class) | ||
public void validatePkce_whenFapiIsTrueAndNoCodeChallenage_shouldThrowError() { | ||
when(appConfiguration.isFapi()).thenReturn(true); | ||
|
||
parValidator.validatePkce(null, null); | ||
} | ||
|
||
@Test | ||
public void validatePkce_whenFapiIsTrueAndCodeChallenageIsSet_shouldNotThrowError() { | ||
when(appConfiguration.isFapi()).thenReturn(true); | ||
|
||
parValidator.validatePkce("codechallangehere", null); | ||
} | ||
|
||
} |