Linting, .git-blame-ignore-revs file
This commit is contained in:
parent
459dd3a6df
commit
1fd190fbb7
2 changed files with 51 additions and 46 deletions
0
.git-blame-ignore-revs
Normal file
0
.git-blame-ignore-revs
Normal file
|
|
@ -453,60 +453,65 @@ describe("AuthDebugger", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("OAuth State Persistence", () => {
|
describe("OAuth State Persistence", () => {
|
||||||
skipIfCI("should store auth state to sessionStorage before redirect in Quick OAuth Flow", async () => {
|
skipIfCI(
|
||||||
const updateAuthState = jest.fn();
|
"should store auth state to sessionStorage before redirect in Quick OAuth Flow",
|
||||||
|
async () => {
|
||||||
|
const updateAuthState = jest.fn();
|
||||||
|
|
||||||
// This test depends on window.location being mocked at the top of the file
|
// This test depends on window.location being mocked at the top of the file
|
||||||
|
|
||||||
// Setup mocks for OAuth flow
|
// Setup mocks for OAuth flow
|
||||||
mockStartAuthorization.mockResolvedValue({
|
mockStartAuthorization.mockResolvedValue({
|
||||||
authorizationUrl: new URL(
|
authorizationUrl: new URL(
|
||||||
"https://oauth.example.com/authorize?client_id=test_client_id&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth%2Fcallback%2Fdebug",
|
"https://oauth.example.com/authorize?client_id=test_client_id&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth%2Fcallback%2Fdebug",
|
||||||
),
|
),
|
||||||
codeVerifier: "test_verifier",
|
codeVerifier: "test_verifier",
|
||||||
});
|
|
||||||
|
|
||||||
await act(async () => {
|
|
||||||
renderAuthDebugger({
|
|
||||||
updateAuthState,
|
|
||||||
authState: { ...defaultAuthState },
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Click Quick OAuth Flow
|
await act(async () => {
|
||||||
await act(async () => {
|
renderAuthDebugger({
|
||||||
fireEvent.click(screen.getByText("Quick OAuth Flow"));
|
updateAuthState,
|
||||||
});
|
authState: { ...defaultAuthState },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wait for the flow to reach the authorization step
|
// Click Quick OAuth Flow
|
||||||
await waitFor(() => {
|
await act(async () => {
|
||||||
expect(sessionStorage.setItem).toHaveBeenCalledWith(
|
fireEvent.click(screen.getByText("Quick OAuth Flow"));
|
||||||
SESSION_KEYS.AUTH_DEBUGGER_STATE,
|
});
|
||||||
expect.stringContaining('"oauthStep":"authorization_code"'),
|
|
||||||
|
// Wait for the flow to reach the authorization step
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(sessionStorage.setItem).toHaveBeenCalledWith(
|
||||||
|
SESSION_KEYS.AUTH_DEBUGGER_STATE,
|
||||||
|
expect.stringContaining('"oauthStep":"authorization_code"'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify the stored state includes all the accumulated data
|
||||||
|
const storedStateCall = (
|
||||||
|
sessionStorage.setItem as jest.Mock
|
||||||
|
).mock.calls.find(
|
||||||
|
(call) => call[0] === SESSION_KEYS.AUTH_DEBUGGER_STATE,
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// Verify the stored state includes all the accumulated data
|
expect(storedStateCall).toBeDefined();
|
||||||
const storedStateCall = (
|
const storedState = JSON.parse(storedStateCall![1] as string);
|
||||||
sessionStorage.setItem as jest.Mock
|
|
||||||
).mock.calls.find((call) => call[0] === SESSION_KEYS.AUTH_DEBUGGER_STATE);
|
|
||||||
|
|
||||||
expect(storedStateCall).toBeDefined();
|
expect(storedState).toMatchObject({
|
||||||
const storedState = JSON.parse(storedStateCall![1] as string);
|
oauthStep: "authorization_code",
|
||||||
|
authorizationUrl: expect.stringMatching(
|
||||||
expect(storedState).toMatchObject({
|
/^https:\/\/oauth\.example\.com\/authorize/,
|
||||||
oauthStep: "authorization_code",
|
),
|
||||||
authorizationUrl: expect.stringMatching(
|
oauthMetadata: expect.objectContaining({
|
||||||
/^https:\/\/oauth\.example\.com\/authorize/,
|
token_endpoint: "https://oauth.example.com/token",
|
||||||
),
|
}),
|
||||||
oauthMetadata: expect.objectContaining({
|
oauthClientInfo: expect.objectContaining({
|
||||||
token_endpoint: "https://oauth.example.com/token",
|
client_id: "test_client_id",
|
||||||
}),
|
}),
|
||||||
oauthClientInfo: expect.objectContaining({
|
});
|
||||||
client_id: "test_client_id",
|
},
|
||||||
}),
|
);
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("OAuth Protected Resource Metadata", () => {
|
describe("OAuth Protected Resource Metadata", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue