-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
src/test/java/it/gov/pagopa/payhub/auth/service/a2a/ClientCredentialsServiceTest.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,40 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.model.generated.AccessToken; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ClientCredentialsServiceTest { | ||
|
||
@Mock | ||
private ValidateClientCredentialsService validateClientCredentialsServiceMock; | ||
private ClientCredentialService service; | ||
|
||
@BeforeEach | ||
void init() { | ||
service = new ClientCredentialServiceImpl(validateClientCredentialsServiceMock); | ||
} | ||
|
||
@Test | ||
void givenValidTokenWhenPostTokenThenSuccess(){ | ||
// Given | ||
String clientId="CLIENT_ID"; | ||
String grantType="GRANT_TYPE";; | ||
String scope="SCOPE"; | ||
String clientSecret="CLIENT_SECRET"; | ||
|
||
Mockito.doNothing().when(validateClientCredentialsServiceMock).validate(clientId, grantType, scope, clientSecret); | ||
AccessToken expectedAccessToken = AccessToken.builder().accessToken("accessToken").build(); | ||
//When | ||
AccessToken result = service.postToken(clientId, grantType, scope, clientSecret); | ||
//Then | ||
Assertions.assertEquals(expectedAccessToken, result); | ||
} | ||
|
||
} |