-
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
11 changed files
with
129 additions
and
58 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
7 changes: 7 additions & 0 deletions
7
src/main/java/it/gov/pagopa/payhub/auth/exception/custom/ClientUnauthorizedException.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,7 @@ | ||
package it.gov.pagopa.payhub.auth.exception.custom; | ||
|
||
public class ClientUnauthorizedException extends RuntimeException { | ||
public ClientUnauthorizedException(String message){ | ||
super(message); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/it/gov/pagopa/payhub/auth/service/a2a/AuthorizeClientCredentialsRequestService.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,19 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class AuthorizeClientCredentialsRequestService { | ||
private final ClientService clientService; | ||
|
||
public AuthorizeClientCredentialsRequestService(ClientService clientService) { | ||
this.clientService = clientService; | ||
} | ||
|
||
public ClientDTO authorizeCredentials(String clientId, String clientSecret) { | ||
return clientService.authorizeCredentials(clientId, clientSecret); | ||
} | ||
} |
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
15 changes: 4 additions & 11 deletions
15
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/ValidateClientCredentialsService.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
36 changes: 36 additions & 0 deletions
36
.../java/it/gov/pagopa/payhub/auth/service/AuthorizeClientCredentialsRequestServiceTest.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,36 @@ | ||
package it.gov.pagopa.payhub.auth.service; | ||
|
||
import it.gov.pagopa.payhub.auth.service.a2a.AuthorizeClientCredentialsRequestService; | ||
import it.gov.pagopa.payhub.auth.service.a2a.ClientService; | ||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
|
||
class AuthorizeClientCredentialsRequestServiceTest { | ||
|
||
@Mock | ||
private ClientService clientService; | ||
private AuthorizeClientCredentialsRequestService service; | ||
|
||
@BeforeEach | ||
void init() { | ||
service = new AuthorizeClientCredentialsRequestService(clientService); | ||
} | ||
|
||
@Test | ||
void givenValidTokenWhenPostTokenThenSuccess(){ | ||
// Given | ||
String clientId="CLIENT_ID"; | ||
String clientSecret="CLIENT_SECRET"; | ||
ClientDTO expectedClientDTO = new ClientDTO(); | ||
|
||
Mockito.doReturn(expectedClientDTO).when(clientService).authorizeCredentials(clientId, clientSecret); | ||
//When | ||
ClientDTO result = service.authorizeCredentials(clientId, clientSecret); | ||
//Then | ||
Assertions.assertEquals(expectedClientDTO, result); | ||
} | ||
} |
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