Skip to content

Commit 4a4d83a

Browse files
committed
Update exercise to use authentication matching, rename extension exercises files
1 parent 08b48a7 commit 4a4d83a

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/test/java/answers/WireMockAnswers2Test.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ public void setupStubExercise204() {
8282

8383
/************************************************
8484
* Create a stub that will respond to a POST request
85-
* to /requestLoan with status code 200,
85+
* to /requestLoan with status code 401,
8686
* but only if:
87-
* - the 'backgroundCheck' header has value 'OK', OR
88-
* - the 'backgroundCheck' header is not present
87+
* - the 'Authorization' header has value 'Bearer invalid', OR
88+
* - the 'Authorization' header is not present
8989
************************************************/
9090

9191
stubFor(post(urlEqualTo("/requestLoan"))
92-
.withHeader("backgroundCheck",
93-
equalTo("OK").or(absent())
92+
.withHeader("Authorization",
93+
equalTo("Bearer invalid").or(absent())
9494
)
9595
.willReturn(aResponse()
96-
.withStatus(200))
96+
.withStatus(401))
9797
);
9898
}
9999

@@ -192,25 +192,25 @@ public void testExercise204() {
192192
given().
193193
spec(requestSpec).
194194
and().
195-
header("backgroundCheck", "OK").
195+
auth().oauth2("invalid").
196196
when().
197197
post("/requestLoan").
198198
then().
199199
assertThat().
200-
statusCode(200);
200+
statusCode(401);
201201

202202
given().
203203
spec(requestSpec).
204204
when().
205205
post("/requestLoan").
206206
then().
207207
assertThat().
208-
statusCode(200);
208+
statusCode(401);
209209

210210
given().
211211
spec(requestSpec).
212212
and().
213-
header("backgroundCheck", "FAILED").
213+
auth().oauth2("valid").
214214
when().
215215
post("/requestLoan").
216216
then().

src/test/java/answers/WireMockAnswers6dot1Test.java renamed to src/test/java/answers/WireMockAnswers7dot1Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1414
import static io.restassured.RestAssured.given;
1515

16-
public class WireMockAnswers6dot1Test {
16+
public class WireMockAnswers7dot1Test {
1717

1818
private RequestSpecification requestSpec;
1919

src/test/java/answers/WireMockAnswers6dot2Test.java renamed to src/test/java/answers/WireMockAnswers7dot2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1717
import static io.restassured.RestAssured.given;
1818

19-
public class WireMockAnswers6dot2Test {
19+
public class WireMockAnswers7dot2Test {
2020

2121
private RequestSpecification requestSpec;
2222

src/test/java/answers/WireMockAnswers6dot3Test.java renamed to src/test/java/answers/WireMockAnswers7dot3Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1717
import static io.restassured.RestAssured.given;
1818

19-
public class WireMockAnswers6dot3Test {
19+
public class WireMockAnswers7dot3Test {
2020

2121
private RequestSpecification requestSpec;
2222

src/test/java/exercises/WireMockExercises2Test.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public void setupStubExercise204() {
6767

6868
/************************************************
6969
* Create a stub that will respond to a POST request
70-
* to /requestLoan with status code 200,
70+
* to /requestLoan with status code 401,
7171
* but only if:
72-
* - the 'backgroundCheck' header has value 'OK', OR
73-
* - the 'backgroundCheck' header is not present
72+
* - the 'Authorization' header has value 'Bearer invalid', OR
73+
* - the 'Authorization' header is not present
7474
************************************************/
7575

7676
}
@@ -163,25 +163,25 @@ public void testExercise204() {
163163
given().
164164
spec(requestSpec).
165165
and().
166-
header("backgroundCheck", "OK").
166+
auth().oauth2("invalid").
167167
when().
168168
post("/requestLoan").
169169
then().
170170
assertThat().
171-
statusCode(200);
171+
statusCode(401);
172172

173173
given().
174174
spec(requestSpec).
175175
when().
176176
post("/requestLoan").
177177
then().
178178
assertThat().
179-
statusCode(200);
179+
statusCode(401);
180180

181181
given().
182182
spec(requestSpec).
183183
and().
184-
header("backgroundCheck", "FAILED").
184+
auth().oauth2("valid").
185185
when().
186186
post("/requestLoan").
187187
then().

src/test/java/exercises/WireMockExercises6dot1Test.java renamed to src/test/java/exercises/WireMockExercises7dot1Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1313
import static io.restassured.RestAssured.given;
1414

15-
public class WireMockExercises6dot1Test {
15+
public class WireMockExercises7dot1Test {
1616

1717
private RequestSpecification requestSpec;
1818

src/test/java/exercises/WireMockExercises6dot2Test.java renamed to src/test/java/exercises/WireMockExercises7dot2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
1717
import static io.restassured.RestAssured.given;
1818

19-
public class WireMockExercises6dot2Test {
19+
public class WireMockExercises7dot2Test {
2020

2121
private RequestSpecification requestSpec;
2222

0 commit comments

Comments
 (0)