Skip to content

Commit

Permalink
adding Serenity and Karate tests to check the example AWS secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
YordanAngelov committed Aug 15, 2022
1 parent db4b89a commit 56105f2
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@AWS
Feature: Check whether AWS features are operational
The `/v1/secrets` endpoint returns a few example secrets to enable us to verify the connection

Scenario: Example Secrets endpoint
Given url base_url.concat(secrets)
And header Authorization = auth.bearer_token
When method GET
Then status 200
* match $ == "Secrets -> SECRET-VALUE-1, SECRET-VALUE-2, SECRET-VALUE-3, SECRET-VALUE-4"
1 change: 1 addition & 0 deletions api-tests-karate/src/test/java/karate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function fn() {
menu: '/v1/menu',
menu_v2: '/v2/menu',
items: '/items',
secrets: '/v1/secrets',

generate_auth0_token: false,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public enum WebServiceEndPoints {
STATUS("/health"),
MENU("/v1/menu"),
MENU_V2("/v2/menu"),
ITEMS("/items");
ITEMS("/items"),
SECRETS("/v1/secrets");

private final String url;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.amido.stacks.tests.api.cloud;

import com.amido.stacks.tests.api.WebServiceEndPoints;
import net.serenitybdd.rest.SerenityRest;
import net.thucydides.core.annotations.Step;

public class AwsFeaturesStatus {

final String BASE_URL = WebServiceEndPoints.BASE_URL.getUrl();

public String expectedExampleSecrets = "Secrets -> SECRET-VALUE-1, SECRET-VALUE-2, SECRET-VALUE-3, SECRET-VALUE-4";

@Step("Get current example secrets")
public void readExampleSecrets() {
SerenityRest.get(BASE_URL + WebServiceEndPoints.SECRETS.getUrl());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.amido.stacks.tests.api.stepdefinitions;

import com.amido.stacks.tests.api.cloud.AwsFeaturesStatus;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.thucydides.core.annotations.Steps;

import static net.serenitybdd.rest.SerenityRest.restAssuredThat;
import static org.hamcrest.Matchers.equalTo;

public class AwsStepDefinitions {

@Steps AwsFeaturesStatus AwsFeaturesStatus;

@When("I check the example secrets")
public void check_the_example_secrets() {
AwsFeaturesStatus.readExampleSecrets();
}

@Then("the API should return the correct examples")
public void the_API_should_return() {
restAssuredThat(lastResponse -> lastResponse.body(equalTo(AwsFeaturesStatus.expectedExampleSecrets)));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@AWS
Feature: Check whether AWS features are operational
The `/v1/secrets` endpoint returns a few example secrets to enable us to verify the connection

Scenario: Example Secrets endpoint
Given the application is running
When I check the example secrets
Then the API should return the correct examples

0 comments on commit 56105f2

Please sign in to comment.