Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public RawAuthResponse(boolean pushEnabled, String token) {
this.pushEnabled = pushEnabled;
this.token = token;

if (token != null && token != "") {
if (token != null && !token.isEmpty()) {
String tokenDecoded = decodeJwt();
this.jwt = Json.fromJson(tokenDecoded, Jwt.class);
} else {
Expand Down
17 changes: 17 additions & 0 deletions client/src/test/java/io/split/engine/sse/AuthApiClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ public void authenticateWithPushDisabledShouldReturnSuccess() throws IOException
Assert.assertTrue(StringUtils.isEmpty(result.getToken()));
}

@Test
public void authenticateWithPushDisabledWithEmptyTokenShouldReturnSuccess() throws IOException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException, URISyntaxException {
CloseableHttpClient httpClientMock = TestHelper.mockHttpClient("streaming-auth-push-disabled-empty-token.json",
HttpStatus.SC_OK);
SplitHttpClient splitHttpClient = SplitHttpClientImpl.create(httpClientMock, new RequestDecorator(null),
"qwerty", metadata());

AuthApiClient authApiClient = new AuthApiClientImp("www.split-test.io", splitHttpClient, TELEMETRY_STORAGE);
AuthenticationResponse result = authApiClient.Authenticate();

Assert.assertFalse(result.isPushEnabled());
Assert.assertTrue(StringUtils.isEmpty(result.getChannels()));
Assert.assertFalse(result.isRetry());
Assert.assertTrue(StringUtils.isEmpty(result.getToken()));
}

@Test
public void authenticateServerErrorShouldReturnErrorWithRetry() throws IOException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException, URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pushEnabled":false,"token":""}