mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Remove AdHoc Access and Token Renewal Pane (#445)
This commit is contained in:
@@ -58,48 +58,4 @@ describe("AuthorizationUtils", () => {
|
||||
).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("displayTokenRenewalPromptForStatus()", () => {
|
||||
let explorer = new Explorer() as jest.Mocked<Explorer>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
window.dataExplorer = explorer;
|
||||
updateConfigContext({
|
||||
platform: Platform.Hosted,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
window.dataExplorer = undefined;
|
||||
});
|
||||
|
||||
it("should not open token renewal prompt if status code is undefined", () => {
|
||||
AuthorizationUtils.displayTokenRenewalPromptForStatus(undefined);
|
||||
expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not open token renewal prompt if status code is null", () => {
|
||||
AuthorizationUtils.displayTokenRenewalPromptForStatus(null);
|
||||
expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not open token renewal prompt if status code is not 401", () => {
|
||||
AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Forbidden);
|
||||
expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not open token renewal prompt if running on a different platform", () => {
|
||||
updateConfigContext({
|
||||
platform: Platform.Portal,
|
||||
});
|
||||
AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Unauthorized);
|
||||
expect(explorer.displayGuestAccessTokenRenewalPrompt).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should open token renewal prompt if running on hosted platform and status code is 401", () => {
|
||||
AuthorizationUtils.displayTokenRenewalPromptForStatus(Constants.HttpStatusCodes.Unauthorized);
|
||||
expect(explorer.displayGuestAccessTokenRenewalPrompt).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,17 +40,3 @@ export function decryptJWTToken(token: string) {
|
||||
|
||||
return JSON.parse(tokenPayload);
|
||||
}
|
||||
|
||||
export function displayTokenRenewalPromptForStatus(httpStatusCode: number): void {
|
||||
const explorer = window.dataExplorer;
|
||||
|
||||
if (
|
||||
httpStatusCode == null ||
|
||||
httpStatusCode != Constants.HttpStatusCodes.Unauthorized ||
|
||||
configContext.platform !== Platform.Hosted
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
explorer.displayGuestAccessTokenRenewalPrompt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user