fix tests
This commit is contained in:
parent
11bc04364b
commit
e74f80db85
2 changed files with 19 additions and 10 deletions
|
|
@ -64,18 +64,22 @@ const AuthDebugger = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (serverUrl && !authState.oauthTokens) {
|
if (serverUrl && !authState.oauthTokens) {
|
||||||
const checkTokens = async () => {
|
const checkTokens = async () => {
|
||||||
const provider = new DebugInspectorOAuthClientProvider(serverUrl);
|
try {
|
||||||
const existingTokens = await provider.tokens();
|
const provider = new DebugInspectorOAuthClientProvider(serverUrl);
|
||||||
if (existingTokens) {
|
const existingTokens = await provider.tokens();
|
||||||
updateAuthState({
|
if (existingTokens) {
|
||||||
oauthTokens: existingTokens,
|
updateAuthState({
|
||||||
oauthStep: "complete",
|
oauthTokens: existingTokens,
|
||||||
});
|
oauthStep: "complete",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load existing OAuth tokens:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
checkTokens();
|
checkTokens();
|
||||||
}
|
}
|
||||||
}, [serverUrl]); // Only run when serverUrl changes
|
}, [serverUrl, updateAuthState, authState.oauthTokens]);
|
||||||
|
|
||||||
const startOAuthFlow = useCallback(() => {
|
const startOAuthFlow = useCallback(() => {
|
||||||
if (!serverUrl) {
|
if (!serverUrl) {
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ describe("AuthDebugger", () => {
|
||||||
|
|
||||||
// Should first discover and save OAuth metadata
|
// Should first discover and save OAuth metadata
|
||||||
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
||||||
"https://example.com",
|
new URL("https://example.com"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that updateAuthState was called with the right info message
|
// Check that updateAuthState was called with the right info message
|
||||||
|
|
@ -314,6 +314,11 @@ describe("AuthDebugger", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(updateAuthState).toHaveBeenCalledWith({
|
expect(updateAuthState).toHaveBeenCalledWith({
|
||||||
|
authServerUrl: null,
|
||||||
|
authorizationUrl: null,
|
||||||
|
isInitiatingAuth: false,
|
||||||
|
resourceMetadata: null,
|
||||||
|
resourceMetadataError: null,
|
||||||
oauthTokens: null,
|
oauthTokens: null,
|
||||||
oauthStep: "metadata_discovery",
|
oauthStep: "metadata_discovery",
|
||||||
latestError: null,
|
latestError: null,
|
||||||
|
|
@ -355,7 +360,7 @@ describe("AuthDebugger", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
|
||||||
"https://example.com",
|
new URL("https://example.com"),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue