-
Couldn't load subscription status.
- Fork 2
RWA-4724: Decouple user creation in individual functional tests #1507
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
Open
adityadwadasi
wants to merge
11
commits into
master
Choose a base branch
from
RWA-4724_ref_fun_tests_users
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ad70b08
RWA-4724: Decouple user creation in individual functional tests
adityadwadasi a5b0895
Fixed checkstyle issues
adityadwadasi 6decc3e
Fixed integration test issues
adityadwadasi be896de
Code cleanup
adityadwadasi 2547da6
baseCaseworkerCredentials refactored
adityadwadasi df97567
Merge branch 'master' into RWA-4724_ref_fun_tests_users
adityadwadasi 4b801fc
Functional tests users creation refactor
adityadwadasi 2177fea
EndpointSecurityTest user creation refactor
adityadwadasi 4c8c0a7
Removed user deletion.
adityadwadasi bfcd315
Updated tests
adityadwadasi f284784
baseCaseworkerCredentials cleanup
adityadwadasi 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,47 +2,50 @@ | |
|
|
||
| import io.restassured.http.Header; | ||
| import io.restassured.response.Response; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.HttpStatus; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.SpringBootFunctionalBaseTest; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.controllers.request.DeleteCaseTasksAction; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.controllers.request.DeleteTasksRequest; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.domain.TestAuthenticationCredentials; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.domain.TestVariables; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.utils.TaskFunctionalTestsApiUtils; | ||
| import uk.gov.hmcts.reform.wataskmanagementapi.utils.TaskFunctionalTestsUserUtils; | ||
|
|
||
| import static uk.gov.hmcts.reform.wataskmanagementapi.config.SecurityConfiguration.AUTHORIZATION; | ||
|
|
||
| public class DeleteTasksByCaseIdControllerTest extends SpringBootFunctionalBaseTest { | ||
|
|
||
| @Autowired | ||
| TaskFunctionalTestsUserUtils taskFunctionalTestsUserUtils; | ||
|
|
||
| @Autowired | ||
| TaskFunctionalTestsApiUtils taskFunctionalTestsApiUtils; | ||
|
|
||
| private static final String ENDPOINT_BEING_TESTED = "task/delete"; | ||
| private TestAuthenticationCredentials caseworkerCredentials; | ||
|
|
||
| private TestAuthenticationCredentials caseworkerWithNoRoles; | ||
|
|
||
| @Before | ||
|
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. We have this @before method in few places , which I believe is uneccessary |
||
| public void setUp() { | ||
| caseworkerCredentials = authorizationProvider.getNewTribunalCaseworker("wa-ft-test-r2-"); | ||
| } | ||
|
|
||
| @After | ||
| public void cleanUp() { | ||
| common.clearAllRoleAssignments(caseworkerCredentials.getHeaders()); | ||
| authorizationProvider.deleteAccount(caseworkerCredentials.getAccount().getUsername()); | ||
| caseworkerWithNoRoles = taskFunctionalTestsUserUtils.getTestUser( | ||
| TaskFunctionalTestsUserUtils.USER_WITH_NO_ROLES); | ||
| } | ||
|
|
||
| @Test | ||
| public void should_return_201_when_task_deleted() { | ||
| final TestVariables taskVariables = common.setupWATaskAndRetrieveIds(); | ||
| final TestVariables taskVariables = taskFunctionalTestsApiUtils.getCommon().setupWATaskAndRetrieveIds(); | ||
| initiateTask(taskVariables); | ||
|
|
||
| final DeleteTasksRequest deleteTasksRequest = new DeleteTasksRequest(new DeleteCaseTasksAction( | ||
| taskVariables.getCaseId())); | ||
|
|
||
| final Response result = restApiActions.post( | ||
| final Response result = taskFunctionalTestsApiUtils.getRestApiActions().post( | ||
| ENDPOINT_BEING_TESTED, | ||
| deleteTasksRequest, | ||
| caseworkerCredentials.getHeaders() | ||
| caseworkerWithNoRoles.getHeaders() | ||
| ); | ||
|
|
||
| result.then().assertThat().statusCode(HttpStatus.CREATED.value()); | ||
|
|
@@ -53,7 +56,7 @@ public void should_return_401_when_when_service_unauthorized() { | |
| final DeleteTasksRequest deleteTasksRequest = new DeleteTasksRequest(new DeleteCaseTasksAction( | ||
| "1234567891234567")); | ||
|
|
||
| final Response result = restApiActions.post( | ||
| final Response result = taskFunctionalTestsApiUtils.getRestApiActions().post( | ||
| ENDPOINT_BEING_TESTED, | ||
| deleteTasksRequest, | ||
| new Header(AUTHORIZATION, "some_invalid_token") | ||
|
|
||
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.
Do we need @before method here?