-
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.
feat: P4ADEV-1102-create-client-revoke-API (#103)
- Loading branch information
1 parent
aa32f53
commit abf6def
Showing
13 changed files
with
239 additions
and
6 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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/revoke/ClientRemovalService.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,20 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a.revoke; | ||
|
||
import it.gov.pagopa.payhub.auth.repository.ClientRepository; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class ClientRemovalService { | ||
|
||
private final ClientRepository clientRepository; | ||
|
||
public ClientRemovalService(ClientRepository clientRepository) { | ||
this.clientRepository = clientRepository; | ||
} | ||
|
||
public void revokeClient(String organizationIpaCode, String clientId) { | ||
clientRepository.deleteByClientIdAndOrganizationIpaCode(clientId, organizationIpaCode); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/test/java/it/gov/pagopa/payhub/auth/service/a2a/revoke/ClientRemovalServiceTest.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,29 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a.revoke; | ||
|
||
import it.gov.pagopa.payhub.auth.repository.ClientRepository; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ClientRemovalServiceTest { | ||
|
||
@Mock | ||
private ClientRepository clientRepository; | ||
@InjectMocks | ||
private ClientRemovalService service; | ||
|
||
@Test | ||
void givenClientIdWhenRevokeClientThenVerifyRevoke() { | ||
// Given | ||
String organizationIpaCode = "organizationIpaCode"; | ||
String clientId = "clientId"; | ||
//When | ||
service.revokeClient(organizationIpaCode, clientId); | ||
//Then | ||
Mockito.verify(clientRepository).deleteByClientIdAndOrganizationIpaCode(clientId, organizationIpaCode); | ||
} | ||
} |