Skip to content

Commit

Permalink
Merge pull request #45 from Ragin-LundF/develop
Browse files Browse the repository at this point in the history
Release 1.23.0
  • Loading branch information
Ragin-LundF authored Dec 15, 2020
2 parents d6d852f + 789a174 commit e89ddc0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Release 1.23.0

## Dependency updates
This release updates some dependencies.

## Set the Bearer token dynamically
To be able to set dynamic bearer token, the following sentence can be used:

```gherkin
Feature: Bearer Token
Scenario: Set bearer token directly
Given that the Bearer token is "abcdefg"
```

This sentence is primary looking into the context map, if there is a key with the given value.
If this is not the case, it uses the given string directly as the token.

Please have a look to the examples at: [src/test/resources/features/header/](src/test/resources/features/header/)


# Release 1.22.0
The `BddCucumberDateTimeFormat` for custom date/time formatters has been changed from `List<String>` with a list
of patterns as string to `List<DateTimeFormatter>`.
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ Feature: User features in global context

Please have a look to the examples at: [src/test/resources/features/user/](src/test/resources/features/user/)

#### Set the Bearer token dynamically
To be able to set dynamic bearer token, the following sentence can be used:

```gherkin
Feature: Bearer Token
Scenario: Set bearer token directly
Given that the Bearer token is "abcdefg"
```

This sentence is primary looking into the context map, if there is a key with the given value.
If this is not the case, it uses the given string directly as the token.

Please have a look to the examples at: [src/test/resources/features/header/](src/test/resources/features/header/)


#### Set path base directory for request/result/database files
```gherkin
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
group=com.ragin.bdd
version=1.22.0
version=1.23.0

systemProp.sonar.host.url=https://sonarcloud.io/
systemProp.sonar.organization=ragin-lundf-github
systemProp.sonar.projectKey=Ragin-LundF_bbd-cucumber-gherkin-lib

versionJavaxJson=1.1.4
versionJsonUnit=2.21.0
versionCucumber=6.8.1
versionJsonUnit=2.22.0
versionCucumber=6.9.0
versionValidationApi=2.0.1.Final
versionCommonsText=1.9
versionCommonsIo=2.8.0
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/ragin/bdd/cucumber/glue/GivenRESTStateGlue.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -163,4 +164,14 @@ public void givenThatJsonHasDifferentArrayOrders() {
public void givenThatStoredDataInContextMapHasBeenReset() {
ScenarioStateContext.current().setScenarioContextMap(new HashMap<>());
}

@Given("that the Bearer token is {string}")
public void givenThatBearerTokenIsUsed(final String bearerToken) {
final String bearerFromContext = ScenarioStateContext.current().getScenarioContextMap().get(bearerToken);
if (Objects.isNull(bearerFromContext)) {
ScenarioStateContext.current().setBearerToken(bearerToken);
} else {
ScenarioStateContext.current().setBearerToken(bearerFromContext);
}
}
}
23 changes: 23 additions & 0 deletions src/test/resources/features/header/header.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@ Feature: Header manipulation
}
"""


Scenario: Set bearer token from context
Given that the context contains the key "NEW_BEARER" with the value "abcdefghij"
Given that the Bearer token is "NEW_BEARER"
When executing an authorized GET call to "/api/v1/overwrittenAuthHeader"
Then I ensure that the status code of the response is 200
And I ensure that the body of the response is equal to
"""
{
"header": "Bearer abcdefghij"
}
"""

Scenario: Set bearer token directly
Given that the Bearer token is "eyabcedfg"
When executing an authorized GET call to "/api/v1/overwrittenAuthHeader"
Then I ensure that the status code of the response is 200
And I ensure that the body of the response is equal to
"""
{
"header": "Bearer eyabcedfg"
}
"""

0 comments on commit e89ddc0

Please sign in to comment.