1515 */
1616package ch .swisscom .mid .client .rest ;
1717
18- import com .github .tomakehurst .wiremock .WireMockServer ;
19- import com .github .tomakehurst .wiremock .http .MimeType ;
20-
21- import org .junit .jupiter .api .AfterAll ;
22- import org .junit .jupiter .api .BeforeAll ;
23- import org .junit .jupiter .api .Test ;
24-
2518import ch .swisscom .mid .client .MIDClient ;
2619import ch .swisscom .mid .client .config .DefaultConfiguration ;
2720import ch .swisscom .mid .client .impl .MIDClientImpl ;
2821import ch .swisscom .mid .client .model .ProfileRequest ;
2922import ch .swisscom .mid .client .model .ProfileResponse ;
3023import ch .swisscom .mid .client .model .SignatureProfiles ;
24+ import com .github .tomakehurst .wiremock .WireMockServer ;
25+ import com .github .tomakehurst .wiremock .http .MimeType ;
26+ import org .junit .jupiter .api .AfterAll ;
27+ import org .junit .jupiter .api .BeforeAll ;
28+ import org .junit .jupiter .api .Test ;
3129
3230import static ch .swisscom .mid .client .rest .TestData .CUSTOM_AP_ID ;
3331import static ch .swisscom .mid .client .rest .TestData .CUSTOM_AP_PASSWORD ;
34- import static ch .swisscom .mid .client .rest .TestSupport .buildConfig ;
35- import static ch .swisscom .mid .client .rest .TestSupport .fileToString ;
36- import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
37- import static com .github .tomakehurst .wiremock .client .WireMock .containing ;
38- import static com .github .tomakehurst .wiremock .client .WireMock .post ;
39- import static com .github .tomakehurst .wiremock .client .WireMock .urlEqualTo ;
32+ import static ch .swisscom .mid .client .rest .TestSupport .*;
33+ import static com .github .tomakehurst .wiremock .client .WireMock .*;
4034import static com .github .tomakehurst .wiremock .core .WireMockConfiguration .options ;
4135import static org .hamcrest .MatcherAssert .assertThat ;
4236import static org .hamcrest .Matchers .contains ;
@@ -51,7 +45,7 @@ public static void setUpThisClass() {
5145 server = new WireMockServer (options ().port (8089 ));
5246 server .start ();
5347
54- client = new MIDClientImpl (buildConfig ());
48+ client = new MIDClientImpl (buildConfig (buildTlsConfig ( "TLSv1.1" ) ));
5549 }
5650
5751 @ AfterAll
@@ -65,31 +59,31 @@ public static void tearDownThisClass() {
6559 @ Test
6660 public void testProfileQuery_success () {
6761 server .stubFor (
68- post (urlEqualTo (DefaultConfiguration .REST_ENDPOINT_SUB_URL ))
69- .willReturn (
70- aResponse ()
71- .withHeader ("Content-Type" , MimeType .JSON .toString ())
72- .withBody (fileToString ("/samples/rest-response-profile-query.json" ))));
62+ post (urlEqualTo (DefaultConfiguration .REST_ENDPOINT_SUB_URL ))
63+ .willReturn (
64+ aResponse ()
65+ .withHeader ("Content-Type" , MimeType .JSON .toString ())
66+ .withBody (fileToString ("/samples/rest-response-profile-query.json" ))));
7367
7468 ProfileRequest request = new ProfileRequest ();
7569 request .getMobileUser ().setMsisdn ("418888888888" );
7670 request .setExtensionParamsToAllValues ();
7771
7872 ProfileResponse response = client .requestProfile (request );
7973 assertThat (response .getSignatureProfiles (),
80- contains (SignatureProfiles .ANY_LOA4 , SignatureProfiles .DEFAULT_PROFILE , SignatureProfiles .STK_LOA4 ));
74+ contains (SignatureProfiles .ANY_LOA4 , SignatureProfiles .DEFAULT_PROFILE , SignatureProfiles .STK_LOA4 ));
8175 }
8276
8377 @ Test
8478 public void testProfileQuery_success_customApIdAndPassword () {
8579 server .stubFor (
86- post (urlEqualTo (DefaultConfiguration .REST_ENDPOINT_SUB_URL ))
87- .withRequestBody (containing ("\" " + CUSTOM_AP_ID + "\" " ))
88- .withRequestBody (containing ("\" " + CUSTOM_AP_PASSWORD + "\" " ))
89- .willReturn (
90- aResponse ()
91- .withHeader ("Content-Type" , MimeType .JSON .toString ())
92- .withBody (fileToString ("/samples/rest-response-profile-query.json" ))));
80+ post (urlEqualTo (DefaultConfiguration .REST_ENDPOINT_SUB_URL ))
81+ .withRequestBody (containing ("\" " + CUSTOM_AP_ID + "\" " ))
82+ .withRequestBody (containing ("\" " + CUSTOM_AP_PASSWORD + "\" " ))
83+ .willReturn (
84+ aResponse ()
85+ .withHeader ("Content-Type" , MimeType .JSON .toString ())
86+ .withBody (fileToString ("/samples/rest-response-profile-query.json" ))));
9387
9488 ProfileRequest request = new ProfileRequest ();
9589 request .getMobileUser ().setMsisdn ("418888888888" );
@@ -99,7 +93,6 @@ public void testProfileQuery_success_customApIdAndPassword() {
9993
10094 ProfileResponse response = client .requestProfile (request );
10195 assertThat (response .getSignatureProfiles (),
102- contains (SignatureProfiles .ANY_LOA4 , SignatureProfiles .DEFAULT_PROFILE , SignatureProfiles .STK_LOA4 ));
96+ contains (SignatureProfiles .ANY_LOA4 , SignatureProfiles .DEFAULT_PROFILE , SignatureProfiles .STK_LOA4 ));
10397 }
104-
10598}
0 commit comments