Skip to content

Commit

Permalink
🪟🎉 Enable keycloak by default (#12037)
Browse files Browse the repository at this point in the history
Co-authored-by: Teal Larson <[email protected]>
  • Loading branch information
timroes and teallarson committed Apr 15, 2024
1 parent 1ddb612 commit fc45d32
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const LoginPage: React.FC = () => {
const { registerNotification } = useNotificationService();
const { trackError } = useAppMonitoringService();
const [searchParams] = useSearchParams();
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", false);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", false);
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", true);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", true);
const keycloakAuthEnabled = keycloakAuthEnabledExperiment || keycloakAuthEnabledLocalStorage;
const loginRedirectString = searchParams.get("loginRedirect");
const isAcceptingInvitation = loginRedirectString?.includes("accept-invite");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ import { OAuthLogin } from "./OAuthLogin";

const mockLoginWithOAuth = jest.fn();

const mockRedirectToSignInWithGithub = jest.fn().mockReturnValue(Promise.resolve());
const mockRedirectToSignInWithGoogle = jest.fn().mockReturnValue(Promise.resolve());

jest.mock("packages/cloud/services/auth/KeycloakService", () => ({
useKeycloakService: () => ({ redirectToSignInWithGithub: jest.fn(), redirectToSignInWithGoogle: jest.fn() }),
useKeycloakService: () => ({
redirectToSignInWithGithub: mockRedirectToSignInWithGithub,
redirectToSignInWithGoogle: mockRedirectToSignInWithGoogle,
}),
}));

describe("OAuthLogin", () => {
Expand All @@ -22,14 +28,14 @@ describe("OAuthLogin", () => {
wrapper: TestWrapper,
});
await userEvents.click(getByTestId("googleOauthLogin"));
expect(mockLoginWithOAuth).toHaveBeenCalledWith("google");
expect(mockRedirectToSignInWithGoogle).toHaveBeenCalled();
});

it("should call auth service for GitHub", async () => {
const { getByTestId } = render(<OAuthLogin loginWithOAuth={mockLoginWithOAuth} type="login" />, {
wrapper: TestWrapper,
});
await userEvents.click(getByTestId("githubOauthLogin"));
expect(mockLoginWithOAuth).toHaveBeenCalledWith("github");
expect(mockRedirectToSignInWithGithub).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export const OAuthLogin: React.FC<OAuthLoginProps> = ({ loginWithOAuth, type })
const [searchParams] = useSearchParams();
const loginRedirect = searchParams.get("loginRedirect");
const navigate = useNavigate();
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", false);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", false);
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", true);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", true);
const keycloakAuthEnabled = keycloakAuthEnabledExperiment || keycloakAuthEnabledLocalStorage;
const {
redirectToSignInWithGithub,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const Detail: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
};

const SignupPage: React.FC<SignupPageProps> = () => {
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", false);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", false);
const [keycloakAuthEnabledLocalStorage] = useLocalStorage("airbyte_keycloak-auth-ui", true);
const keycloakAuthEnabledExperiment = useExperiment("authPage.keycloak", true);
const keycloakAuthEnabled = keycloakAuthEnabledExperiment || keycloakAuthEnabledLocalStorage;
const { loginWithOAuth, signUp } = useAuthService();
useTrackPage(PageTrackingCodes.SIGNUP);
Expand Down

0 comments on commit fc45d32

Please sign in to comment.