Skip to content

Commit

Permalink
Merge pull request #1 from wiremock/remove-mocklab-references
Browse files Browse the repository at this point in the history
Remove mocklab references and replace with wiremock
  • Loading branch information
leeturner authored Apr 16, 2024
2 parents e16eb0c + ffc05a8 commit aa5e92c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public Object apply(Object context, Options options) {
JWTCreator.Builder tokenBuilder = JWT.create()
.withExpiresAt(expiryDate)
.withIssuedAt(new Date())
.withIssuer(getOptionOrDefault(options, "iss", "mocklab"))
.withAudience(getOptionOrDefault(options, "aud", "mocklab.io"))
.withIssuer(getOptionOrDefault(options, "iss", "wiremock"))
.withAudience(getOptionOrDefault(options, "aud", "wiremock.io"))
.withSubject(getOptionOrDefault(options, "sub", "user-123"));

if (options.hash.containsKey("nbf")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void init() {
void produces_default_jwt_with_100_year_lifetime_when_no_parameters_specified() {
DecodedJWT decodedJwt = verifyHs256AndDecodeForTemplate("{{jwt}}");

assertThat(decodedJwt.getIssuer(), is("mocklab"));
assertThat(decodedJwt.getAudience().get(0), is("mocklab.io"));
assertThat(decodedJwt.getIssuer(), is("wiremock"));
assertThat(decodedJwt.getAudience().get(0), is("wiremock.io"));
inLastFewSeconds(decodedJwt.getIssuedAt());
inTheFutureFrom(decodedJwt.getExpiresAt(), decodedJwt.getIssuedAt(), 36500, DAYS);
}
Expand Down Expand Up @@ -128,9 +128,9 @@ void produces_a_JWT_with_the_supplied_not_before_date() {
@Test
void produces_a_JWT_with_the_supplied_issuer() {
DecodedJWT decodedJwt =
verifyHs256AndDecodeForTemplate("{{jwt iss='https://jwt-example.mocklab.io/'}}");
verifyHs256AndDecodeForTemplate("{{jwt iss='https://jwt-example.wiremock.io/'}}");

assertThat(decodedJwt.getIssuer(), is("https://jwt-example.mocklab.io/"));
assertThat(decodedJwt.getIssuer(), is("https://jwt-example.wiremock.io/"));
}

@Test
Expand All @@ -143,24 +143,24 @@ void produces_a_JWT_with_the_supplied_subject() {
@Test
void produces_a_JWT_with_the_supplied_single_audience() {
DecodedJWT decodedJwt =
verifyHs256AndDecodeForTemplate("{{jwt aud='https://jwt-target.mocklab.io/'}}");
verifyHs256AndDecodeForTemplate("{{jwt aud='https://jwt-target.wiremock.io/'}}");

assertThat(decodedJwt.getAudience().get(0), is("https://jwt-target.mocklab.io/"));
assertThat(decodedJwt.getAudience().get(0), is("https://jwt-target.wiremock.io/"));
}

@Test
void produces_a_JWT_with_custom_claims() {
DecodedJWT decodedJwt =
verifyHs256AndDecodeForTemplate(
"{{jwt sub='superuser' isAdmin=true quota=23 score=0.96 email='superuser@example.mocklab.io' signupDate=(parseDate '2017-01-02T03:04:05Z')}}");
"{{jwt sub='superuser' isAdmin=true quota=23 score=0.96 email='superuser@example.wiremock.io' signupDate=(parseDate '2017-01-02T03:04:05Z')}}");

assertThat(decodedJwt.getSubject(), is("superuser"));
Map<String, Claim> claims = decodedJwt.getClaims();

assertThat(claims.get("isAdmin").asBoolean(), is(true));
assertThat(claims.get("quota").asInt(), is(23));
assertThat(claims.get("score").asDouble(), is(0.96));
assertThat(claims.get("email").asString(), is("superuser@example.mocklab.io"));
assertThat(claims.get("email").asString(), is("superuser@example.wiremock.io"));
assertThat(claims.get("signupDate").asDate(), is(Dates.parse("2017-01-02T03:04:05Z")));
}

Expand Down

0 comments on commit aa5e92c

Please sign in to comment.