-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DTSRD-2133. Delete organisation and user from UP even if he is in active status #1590
Open
SabinaHMCTS
wants to merge
41
commits into
master
Choose a base branch
from
DTSRD-2133
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
c06c1a6
Upgrading perftest branch to V16 and adding subnet_suffix
SabinaHMCTS 443246f
Delete organisation and user even if he is active
SabinaHMCTS 2937807
Delete User
SabinaHMCTS ed8ec38
Delete User and User Profile
SabinaHMCTS ee25438
Delete User and User Profile
SabinaHMCTS d67d971
Delete User and User Profile
SabinaHMCTS f9b6715
Delete User and User Profile
SabinaHMCTS 510e09d
Delete User and User Profile
SabinaHMCTS 0df25e2
Delete User and User Profile
SabinaHMCTS 3dd7caf
Fix build
SabinaHMCTS 76c03eb
Fix build
SabinaHMCTS 10b6973
Fix build
SabinaHMCTS bf2049e
Fix build
SabinaHMCTS 1924b8b
Fix build
SabinaHMCTS 0132dbc
Fix build
SabinaHMCTS b1c7ca4
Fix build
SabinaHMCTS 5fe76bb
Fix build
SabinaHMCTS 42df77c
Fix build
SabinaHMCTS 57fb69d
Fix build
SabinaHMCTS 3a20702
Fix build
SabinaHMCTS af226cb
Fix build
SabinaHMCTS 9d27d99
Fix build
SabinaHMCTS 1ebfb97
Fix build
SabinaHMCTS 7b24fe2
Fix build
SabinaHMCTS 02cc226
Fix build
SabinaHMCTS 5c6303e
Fix build
SabinaHMCTS f6a7fd4
Merge branch 'master' into DTSRD-2133
SabinaHMCTS f07b996
fixing review comments
SabinaHMCTS d08920f
fixing review comments
SabinaHMCTS 3806151
fixing review comments
SabinaHMCTS 5fcc971
removed teh extra code for DTSRD-2134
SabinaHMCTS c82455f
removed teh extra code for DTSRD-2134
SabinaHMCTS 47e5a12
removed teh extra code for DTSRD-2134
SabinaHMCTS 725c733
removed teh extra code for DTSRD-2134
SabinaHMCTS a293465
Merge branch 'master' into DTSRD-2133
SabinaHMCTS 3f0f0e2
removed teh extra code for DTSRD-2134
SabinaHMCTS 2045d1e
removed teh extra code for DTSRD-2134
SabinaHMCTS b4ef9dc
Merge branch 'master' into DTSRD-2133
SabinaHMCTS c4da7af
merging DTSRD-2132 and DTSRD-2136
SabinaHMCTS c1c2d81
endpoint to save SraId
SabinaHMCTS 83caf02
endpoint to save SraId
SabinaHMCTS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,15 +89,14 @@ void return_404_when_un_known_org_identifier_in_the_request_to_delete_pending_or | |
} | ||
|
||
@Test | ||
void returns_400_with_error_msg_when_delete_active_organisation_with_active_user_profile() { | ||
void returns_200_when_delete_active_organisation_with_active_user_profile() { | ||
userProfileCreateUserWireMock(HttpStatus.resolve(201)); | ||
String orgIdentifier = createAndActivateOrganisation(); | ||
|
||
getUserProfileByEmailWireMock(HttpStatus.resolve(200)); | ||
deleteUserProfileMock(HttpStatus.resolve(204)); | ||
Map<String, Object> deleteResponse = | ||
professionalReferenceDataClient.deleteOrganisation(hmctsAdmin, orgIdentifier); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo("400"); | ||
assertThat((String) deleteResponse.get("response_body")) | ||
.contains("The organisation admin is not in Pending state"); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo(204); | ||
|
||
} | ||
|
||
|
@@ -114,13 +113,14 @@ void returns_204_when_delete_active_organisation_with_one_pending_user_profile() | |
} | ||
|
||
@Test | ||
void returns_400_when_delete_active_organisation_with_more_than_one__user_profile() { | ||
void returns_200_when_delete_active_organisation_with_more_than_one_user_profile() { | ||
List<String> userRoles = new ArrayList<>(); | ||
userRoles.add("pui-user-manager"); | ||
|
||
userProfileCreateUserWireMock(HttpStatus.resolve(201)); | ||
String orgIdentifier = createAndActivateOrganisation(); | ||
|
||
getUserProfileByEmailWireMock(HttpStatus.resolve(200)); | ||
deleteUserProfileMock(HttpStatus.resolve(204)); | ||
Map<String, Object> newUserResponse = professionalReferenceDataClient | ||
.addUserToOrganisation(orgIdentifier, | ||
inviteUserCreationRequest("[email protected]", userRoles), hmctsAdmin); | ||
|
@@ -132,7 +132,7 @@ void returns_400_when_delete_active_organisation_with_more_than_one__user_profil | |
|
||
Map<String, Object> deleteResponse = | ||
professionalReferenceDataClient.deleteOrganisation(hmctsAdmin, orgIdentifier); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo("400"); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo(204); | ||
} | ||
|
||
@Test | ||
|
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 |
---|---|---|
|
@@ -77,15 +77,14 @@ void return_forbidden_when_no_role_associated_with_end_point_to_delete_pending_o | |
|
||
|
||
@Test | ||
void returns_400_with_error_msg_when_delete_active_otherOrganisation_with_active_user_profile() { | ||
void returns_200_with_error_msg_when_delete_active_otherOrganisation_with_active_user_profile() { | ||
userProfileCreateUserWireMock(HttpStatus.resolve(201)); | ||
String orgIdentifier = createAndActivateOtherOrganisation(); | ||
|
||
getUserProfileByEmailWireMock(HttpStatus.resolve(200)); | ||
deleteUserProfileMock(HttpStatus.resolve(204)); | ||
Map<String, Object> deleteResponse = | ||
professionalReferenceDataClient.deleteOrganisation(hmctsAdmin, orgIdentifier); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo("400"); | ||
assertThat((String) deleteResponse.get("response_body")) | ||
.contains("The organisation admin is not in Pending state"); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo(204); | ||
|
||
} | ||
|
||
|
@@ -102,13 +101,16 @@ void returns_204_when_delete_active_otherOrganisation_with_one_pending_user_prof | |
} | ||
|
||
@Test | ||
void returns_400_when_delete_active_otherOrganisation_with_more_than_one__user_profile() { | ||
void returns_200_when_delete_active_otherOrganisation_with_more_than_one__user_profile() { | ||
List<String> userRoles = new ArrayList<>(); | ||
userRoles.add("pui-user-manager"); | ||
|
||
userProfileCreateUserWireMock(HttpStatus.resolve(201)); | ||
String orgIdentifier = createAndActivateOtherOrganisation(); | ||
|
||
getUserProfileByEmailWireMock(HttpStatus.resolve(200)); | ||
deleteUserProfileMock(HttpStatus.resolve(204)); | ||
|
||
Map<String, Object> newUserResponse = professionalReferenceDataClient | ||
.addUserToOrganisation(orgIdentifier, | ||
inviteUserCreationRequest("[email protected]", userRoles), hmctsAdmin); | ||
|
@@ -118,9 +120,11 @@ void returns_400_when_delete_active_otherOrganisation_with_more_than_one__user_p | |
assertThat(newUserResponse).isNotNull(); | ||
assertEquals(newUserResponse.get(USER_IDENTIFIER), userIdentifierResponse); | ||
|
||
|
||
|
||
Map<String, Object> deleteResponse = | ||
professionalReferenceDataClient.deleteOrganisation(hmctsAdmin, orgIdentifier); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo("400"); | ||
assertThat(deleteResponse.get("http_status")).isEqualTo(204); | ||
} | ||
|
||
@Test | ||
|
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
31 changes: 31 additions & 0 deletions
31
...main/java/uk/gov/hmcts/reform/professionalapi/controller/request/UserDeletionRequest.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,31 @@ | ||
package uk.gov.hmcts.reform.professionalapi.controller.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@Builder(builderMethodName = "userDeletionRequest") | ||
public class UserDeletionRequest { | ||
|
||
private String firstName; | ||
private String lastName; | ||
private List<String> emails; | ||
|
||
@JsonCreator | ||
public UserDeletionRequest( | ||
@JsonProperty("firstName") String firstName, | ||
@JsonProperty("lastName") String lastName, | ||
@JsonProperty("emails") List<String> emails | ||
) { | ||
|
||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.emails = emails; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...main/java/uk/gov/hmcts/reform/professionalapi/controller/response/DeleteUserResponse.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,17 @@ | ||
package uk.gov.hmcts.reform.professionalapi.controller.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DeleteUserResponse { | ||
|
||
private int statusCode; | ||
private String message; | ||
|
||
} |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package uk.gov.hmcts.reform.professionalapi.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
import uk.gov.hmcts.reform.professionalapi.domain.UserAttribute; | ||
|
||
|
@@ -9,4 +11,9 @@ | |
@Repository | ||
public interface UserAttributeRepository extends JpaRepository<UserAttribute, UUID> { | ||
|
||
@Modifying | ||
@Query(value = "delete from dbrefdata.user_attribute ua where ua.professional_user_id = :profUserId ", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you need this native, try cascade delete |
||
nativeQuery = true) | ||
void deleteByProfessionalUserId(UUID profUserId); | ||
|
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing functional tests