-
Notifications
You must be signed in to change notification settings - Fork 83
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): added ability to set client expiration via DCR …
…#5057 (#5185) * feat(jans-auth-server): add ability to set client expiration via DCR #5057 * feat(jans-auth-server): added test for client expiration via DCR #5057 * feat(jans-auth-server): flip parmeters for equals assertion #5057 * feat(jans-auth-server): corrected references in swagger and doc #5057 * feat(jans-auth-server): sonar fixes #5057
- Loading branch information
Showing
11 changed files
with
183 additions
and
4 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
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
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
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
94 changes: 94 additions & 0 deletions
94
...erver/src/test/java/io/jans/as/server/register/ws/rs/action/RegisterCreateActionTest.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,94 @@ | ||
package io.jans.as.server.register.ws.rs.action; | ||
|
||
import io.jans.as.client.RegisterRequest; | ||
import io.jans.as.common.service.common.InumService; | ||
import io.jans.as.model.config.StaticConfiguration; | ||
import io.jans.as.model.configuration.AppConfiguration; | ||
import io.jans.as.model.error.ErrorResponseFactory; | ||
import io.jans.as.server.audit.ApplicationAuditLogger; | ||
import io.jans.as.server.model.registration.RegisterParamsValidator; | ||
import io.jans.as.server.register.ws.rs.RegisterJsonService; | ||
import io.jans.as.server.register.ws.rs.RegisterService; | ||
import io.jans.as.server.register.ws.rs.RegisterValidator; | ||
import io.jans.as.server.service.ClientService; | ||
import io.jans.as.server.service.external.ExternalDynamicClientRegistrationService; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Spy; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.slf4j.Logger; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.mockito.Mockito.when; | ||
import static org.testng.Assert.assertEquals; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
@SuppressWarnings("java:S5979") | ||
@Listeners(MockitoTestNGListener.class) | ||
public class RegisterCreateActionTest { | ||
|
||
@InjectMocks | ||
@Spy | ||
private RegisterCreateAction registerCreateAction; | ||
|
||
@Mock | ||
private Logger log; | ||
|
||
@Mock | ||
private ApplicationAuditLogger applicationAuditLogger; | ||
|
||
@Mock | ||
private ErrorResponseFactory errorResponseFactory; | ||
|
||
@Mock | ||
private InumService inumService; | ||
|
||
@Mock | ||
private ClientService clientService; | ||
|
||
@Mock | ||
private ExternalDynamicClientRegistrationService externalDynamicClientRegistrationService; | ||
|
||
@Mock | ||
private RegisterParamsValidator registerParamsValidator; | ||
|
||
@Mock | ||
private AppConfiguration appConfiguration; | ||
|
||
@Mock | ||
private StaticConfiguration staticConfiguration; | ||
|
||
@Mock | ||
private RegisterValidator registerValidator; | ||
|
||
@Mock | ||
private RegisterJsonService registerJsonService; | ||
|
||
@Mock | ||
private RegisterService registerService; | ||
|
||
@Test | ||
public void getClientLifetime_whenUpdateForbiddenInRequest_shouldReturnValueFromServerConfiguration() { | ||
when(appConfiguration.getDynamicRegistrationExpirationTime()).thenReturn(10); | ||
when(appConfiguration.getDcrForbidExpirationTimeInRequest()).thenReturn(true); | ||
|
||
RegisterRequest request = new RegisterRequest(); | ||
request.setLifetime(5); | ||
|
||
assertEquals(registerCreateAction.getClientLifetime(request), 10); | ||
} | ||
|
||
@Test | ||
public void getClientLifetime_whenUpdateIsNotForbiddenInRequest_shouldReturnValueFromRequest() { | ||
when(appConfiguration.getDynamicRegistrationExpirationTime()).thenReturn(10); | ||
when(appConfiguration.getDcrForbidExpirationTimeInRequest()).thenReturn(false); | ||
|
||
RegisterRequest request = new RegisterRequest(); | ||
request.setLifetime(5); | ||
|
||
assertEquals(registerCreateAction.getClientLifetime(request), 5); | ||
} | ||
} |
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
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