Skip to content

Commit

Permalink
Handle login.html incorrect validation for PL
Browse files Browse the repository at this point in the history
  • Loading branch information
satviksr-db committed Sep 3, 2024
1 parent c9fb324 commit 04c6371
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public String errorMessage() {

public static boolean isPrivateLinkRedirect(Response resp) {
return resp.getUrl().getPath().equals("/login.html")
&& resp.getUrl().getQuery().contains("error=private-link-validation-error");
&& (resp.getUrl().getQuery() != null
&& resp.getUrl().getQuery().contains("error=private-link-validation-error"));
}

static PrivateLinkValidationError createPrivateLinkValidationError(Response resp) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.databricks.sdk.core.error;

import com.databricks.sdk.core.error.platform.*;
import com.databricks.sdk.core.http.Request;
import com.databricks.sdk.core.http.Response;
import org.junit.jupiter.api.Test;

public class PrivateLinkInfoTest {
@Test
void testIsPrivateLinkRedirectWithLoginHtmlAndQueryParamSet() {
Response response =
new Response(
new Request("GET", "https://example.com/login.html")
.withQueryParam("error", "private-link-validation-error"),
307,
"Temporary Redirect",
null);
assert PrivateLinkInfo.isPrivateLinkRedirect(response) == true;
}

@Test
void testIsPrivateLinkRedirectWithLoginHtmlAndQueryParamNotSet() {
Response response =
new Response(
new Request("GET", "https://example.com/login.html"), 307, "Temporary Redirect", null);
assert PrivateLinkInfo.isPrivateLinkRedirect(response) == false;
}

@Test
void testIsPrivateLinkRedirectNotLoginPage() {
Response response =
new Response(
new Request("GET", "https://example.com/not-login.html"),
307,
"Temporary Redirect",
null);
assert PrivateLinkInfo.isPrivateLinkRedirect(response) == false;
}
}

0 comments on commit 04c6371

Please sign in to comment.