File tree 2 files changed +21
-3
lines changed
main/java/io/visual_regression_tracker/sdk_java
test/java/io/visual_regression_tracker/sdk_java
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,15 @@ protected void startBuild() throws IOException {
45
45
.build ();
46
46
47
47
try (Response response = client .newCall (request ).execute ()) {
48
- if (response .code () == 404 ) {
49
- throw new TestRunException ("Project not found" );
50
- }
51
48
if (response .code () == 401 ) {
52
49
throw new TestRunException ("Unauthorized" );
53
50
}
51
+ if (response .code () == 403 ) {
52
+ throw new TestRunException ("Api key not authenticated" );
53
+ }
54
+ if (response .code () == 404 ) {
55
+ throw new TestRunException ("Project not found" );
56
+ }
54
57
55
58
String responseBody = Optional .ofNullable (response .body ())
56
59
.orElseThrow (() -> new TestRunException ("Cannot get response body" ))
Original file line number Diff line number Diff line change @@ -102,6 +102,21 @@ public void shouldThrowExceptionIfUnauthorized() throws IOException {
102
102
MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Unauthorized" ));
103
103
}
104
104
105
+ @ Test
106
+ public void shouldThrowExceptionIfForbidden () throws IOException {
107
+ server .enqueue (new MockResponse ()
108
+ .setResponseCode (403 )
109
+ .setBody ("{\r \n \" statusCode\" : 403,\r \n \" message\" : \" Forbidden\" \r \n }" ));
110
+
111
+ String exceptionMessage = "" ;
112
+ try {
113
+ vrt .startBuild ();
114
+ } catch (TestRunException ex ) {
115
+ exceptionMessage = ex .getMessage ();
116
+ }
117
+ MatcherAssert .assertThat (exceptionMessage , CoreMatchers .is ("Api key not authenticated" ));
118
+ }
119
+
105
120
@ Test
106
121
public void shouldSubmitTestRun () throws IOException , InterruptedException {
107
122
String buildId = "123123" ;
You can’t perform that action at this time.
0 commit comments