mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 19:01:28 +00:00
Compare commits
4 Commits
tsStrict/f
...
generated-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4fd56ecb0 | ||
|
|
a8eeeebb59 | ||
|
|
abe491f5cd | ||
|
|
2fc15cf322 |
@@ -1,6 +1,13 @@
|
||||
import { armRequest } from "./request";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
describe("ARM request", () => {
|
||||
beforeAll(() => {
|
||||
updateUserContext({
|
||||
authorizationToken: "foo"
|
||||
});
|
||||
});
|
||||
|
||||
it("should call window.fetch", async () => {
|
||||
window.fetch = jest.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
|
||||
@@ -24,11 +24,15 @@ interface Options {
|
||||
// TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them.
|
||||
export async function armRequest<T>({ host, path, apiVersion, method, body: requestBody }: Options): Promise<T> {
|
||||
const url = new URL(path, host);
|
||||
const authHeader = userContext.authorizationToken;
|
||||
if (!authHeader) {
|
||||
throw new Error("No ARM authorization header provided");
|
||||
}
|
||||
url.searchParams.append("api-version", apiVersion);
|
||||
const response = await window.fetch(url.href, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: userContext.authorizationToken
|
||||
Authorization: authHeader
|
||||
},
|
||||
body: requestBody ? JSON.stringify(requestBody) : undefined
|
||||
});
|
||||
@@ -71,9 +75,13 @@ interface OperationResponse {
|
||||
}
|
||||
|
||||
async function getOperationStatus(operationStatusUrl: string) {
|
||||
const authHeader = userContext.authorizationToken;
|
||||
if (!authHeader) {
|
||||
throw new Error("No ARM authorization header provided");
|
||||
}
|
||||
const response = await window.fetch(operationStatusUrl, {
|
||||
headers: {
|
||||
Authorization: userContext.authorizationToken
|
||||
Authorization: authHeader
|
||||
}
|
||||
});
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"./src/Contracts/Versions.ts",
|
||||
"./src/Controls/Heatmap/Heatmap.ts",
|
||||
"./src/Controls/Heatmap/HeatmapDatatypes.ts",
|
||||
"./src/DefaultAccountExperienceType.ts",
|
||||
"./src/Definitions/globals.d.ts",
|
||||
"./src/Definitions/html.d.ts",
|
||||
"./src/Definitions/jquery-ui.d.ts",
|
||||
@@ -66,11 +67,31 @@
|
||||
"./src/Shared/Telemetry/TelemetryProcessor.ts",
|
||||
"./src/Shared/appInsights.ts",
|
||||
"./src/UserContext.ts",
|
||||
"./src/Utils/Base64Utils.ts",
|
||||
"./src/Utils/GitHubUtils.ts",
|
||||
"./src/Utils/MessageValidation.ts",
|
||||
"./src/Utils/OfferUtils.ts",
|
||||
"./src/Utils/StringUtils.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/cassandraResources.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/collection.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/collectionPartition.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/collectionPartitionRegion.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/collectionRegion.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/database.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/databaseAccountRegion.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/databaseAccounts.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/gremlinResources.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/mongoDBResources.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/operations.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeId.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/partitionKeyRangeIdRegion.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/percentile.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/percentileSourceTarget.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/percentileTarget.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/sqlResources.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/tableResources.ts",
|
||||
"./src/Utils/arm/generatedClients/2020-04-01/types.ts",
|
||||
"./src/Utils/arm/request.ts",
|
||||
"./src/quickstart.ts",
|
||||
"./src/setupTests.ts",
|
||||
"./src/workers/upload/definitions.ts"
|
||||
|
||||
Reference in New Issue
Block a user