Skip to content

Commit

Permalink
Tests for PO-690 (#602)
Browse files Browse the repository at this point in the history
Co-authored-by: rajanigandra <[email protected]>
  • Loading branch information
CadeFaulkner and rajanigandra authored Oct 22, 2024
1 parent b364c3b commit a48c42a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.cucumber.java.en.And;
import io.cucumber.java.en.When;
import net.serenitybdd.rest.SerenityRest;
import org.json.JSONException;
import uk.gov.hmcts.opal.steps.BaseStepDef;
import uk.gov.hmcts.opal.utils.DraftAccountUtils;

Expand All @@ -27,6 +28,47 @@ public void getDraftAccount(String draftAccountId) {
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "/" + draftAccountId);
}

@When("I get the draft account trying to provoke an internal server error")
public void getDraftAccountInternalServerError() {
SerenityRest
.given()
.urlEncodingEnabled(false)
.header("Authorization", "Bearer " + getToken())
.accept("*/*")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "/%20");
}

@When("I attempt to get a draft account with an invalid token")
public void getDraftAccountWithInvalidToken() throws JSONException {
SerenityRest
.given()
.header("Authorization", "Bearer " + "invalidToken")
.accept("*/*")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "/1234");
}

@When("I attempt to get a draft account with an unsupported content type")
public void getDraftAccountWithUnsupportedContentType() throws JSONException {
assertEquals(
1,
DraftAccountUtils.getAllDraftAccountIds().size(),
"There should be only one draft account but found multiple: "
+ DraftAccountUtils.getAllDraftAccountIds()
);
String draftAccountId = DraftAccountUtils.getAllDraftAccountIds().getFirst();
SerenityRest
.given()
.header("Authorization", "Bearer " + getToken())
.accept("text/plain")
.contentType("application/json")
.when()
.get(getTestUrl() + DRAFT_ACCOUNT_URI + "/" + draftAccountId);
}

@When("I get the single created draft account and the response contains")
public void getSingleDraftAccount(DataTable data) {
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
@Opal
Feature: PO-690 get draft account error handling

Feature: PO-690 get draft account error handling scenarios

@PO-690
#When request includes an invalid access token or does not include access token
Scenario: Get draft account id - unhappy path -Response code 401
@PO-690 @cleanUpData
Scenario: Get draft account - CEP2 - Invalid or No Access Token
Given I am testing as the "[email protected]" user
When I request the draft account id with invalid token
When I attempt to get a draft account with an invalid token
Then The draft account response returns 401
Then I delete the created draft accounts

Scenario: Get draft account id - unhappy path -Response code 404
@PO-690 @cleanUpData
Scenario: Get draft account - CEP4 - Resource Not Found
Given I am testing as the "[email protected]" user
When I request the draft account with incorrect account id
When I attempt to hit an endpoint that doesn't exist
Then The draft account response returns 404
Then I delete the created draft accounts

Scenario: Get draft account id - unhappy path -Response code 406

@PO-690 @cleanUpData
Scenario: Get draft account - CEP5 - Unsupported Content Type
Given I am testing as the "[email protected]" user
When I request the draft account with content type mismatch
Then The draft account response returns 404
Then I delete the created draft accounts
When I create a draft account with the following details
| business_unit_id | 73 |
| account | draftAccounts/accountJson/account.json |
| account_type | Fine |
| account_status | |
| submitted_by | BUUID |
| timeline_data | |
Then The draft account response returns 201
And I store the created draft account ID

When I attempt to get a draft account with an unsupported content type
Then The draft account response returns 406

@PO-690 @cleanUpData
Scenario: Get draft account - CEP5 - Unsupported Content Type in Url parameter
Given I am testing as the "[email protected]" user
When I get the draft account "not A Long"
Then The draft account response returns 406


@PO-690 @cleanUpData
Scenario: Get draft account - CEP9 - Other Server Error
Given I am testing as the "[email protected]" user
When I get the draft account trying to provoke an internal server error
Then The draft account response returns 500

0 comments on commit a48c42a

Please sign in to comment.