mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
Merge branch 'master' into remove-redundant-e2e-tests
This commit is contained in:
commit
ff1cb5603b
@ -1,5 +1,4 @@
|
||||
import { AutopilotTier } from "../Contracts/DataModels";
|
||||
import { configContext } from "../ConfigContext";
|
||||
import { HashMap } from "./HashMap";
|
||||
|
||||
export class AuthorizationEndpoints {
|
||||
@ -13,12 +12,6 @@ export class CodeOfConductEndpoints {
|
||||
public static termsOfUse: string = "https://aka.ms/ms-terms-of-use";
|
||||
}
|
||||
|
||||
export class BackendEndpoints {
|
||||
public static localhost: string = "https://localhost:12900";
|
||||
public static dev: string = "https://ext.documents-dev.windows-int.net";
|
||||
public static productionPortal: string = configContext.BACKEND_ENDPOINT || "https://main.documentdb.ext.azure.com";
|
||||
}
|
||||
|
||||
export class EndpointsRegex {
|
||||
public static readonly cassandra = [
|
||||
"AccountEndpoint=(.*).cassandra.cosmosdb.azure.com",
|
||||
|
@ -14,7 +14,9 @@ describe("tokenProvider", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
window.dataExplorer = { extensionEndpoint: () => "https://main.documentdb.ext.azure.com" } as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
json: () => "{}",
|
||||
@ -58,7 +60,9 @@ describe("getTokenFromAuthService", () => {
|
||||
});
|
||||
|
||||
it("builds the correct URL in production", () => {
|
||||
window.dataExplorer = { extensionEndpoint: () => "https://main.documentdb.ext.azure.com" } as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
getTokenFromAuthService("GET", "dbs", "foo");
|
||||
expect(window.fetch).toHaveBeenCalledWith(
|
||||
"https://main.documentdb.ext.azure.com/api/guest/runtimeproxy/authorizationTokens",
|
||||
|
@ -52,7 +52,7 @@ export const endpoint = () => {
|
||||
|
||||
export async function getTokenFromAuthService(verb: string, resourceType: string, resourceId?: string): Promise<any> {
|
||||
try {
|
||||
const host = configContext.BACKEND_ENDPOINT || _global.dataExplorer.extensionEndpoint();
|
||||
const host = configContext.BACKEND_ENDPOINT;
|
||||
const response = await _global.fetch(host + "/api/guest/runtimeproxy/authorizationTokens", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@ -85,8 +85,7 @@ export function client(): Cosmos.CosmosClient {
|
||||
userAgentSuffix: "Azure Portal"
|
||||
};
|
||||
|
||||
// In development we proxy requests to the backend via webpack. This is removed in production bundles.
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (configContext.PROXY_PATH !== undefined) {
|
||||
(options as any).plugins = [{ on: "request", plugin: requestPlugin }];
|
||||
}
|
||||
return new Cosmos.CosmosClient(options);
|
||||
|
@ -63,10 +63,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -96,10 +95,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -129,10 +127,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -162,10 +159,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -195,10 +191,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
window.fetch = jest.fn().mockImplementation(fetchMock);
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -229,10 +224,9 @@ describe("MongoProxyClient", () => {
|
||||
updateUserContext({
|
||||
databaseAccount
|
||||
});
|
||||
window.dataExplorer = {
|
||||
extensionEndpoint: () => "https://main.documentdb.ext.azure.com",
|
||||
serverId: () => ""
|
||||
} as any;
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com"
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a production endpoint", () => {
|
||||
|
@ -327,8 +327,7 @@ export function createMongoCollectionWithProxy(
|
||||
}
|
||||
|
||||
export function getEndpoint(): string {
|
||||
const extensionEndpoint = window.dataExplorer.extensionEndpoint();
|
||||
let url = (configContext.MONGO_BACKEND_ENDPOINT || extensionEndpoint) + "/api/mongo/explorer";
|
||||
let url = (configContext.MONGO_BACKEND_ENDPOINT || configContext.BACKEND_ENDPOINT) + "/api/mongo/explorer";
|
||||
|
||||
if (window.authType === AuthType.EncryptedToken) {
|
||||
url = url.replace("api/mongo", "api/guest/mongo");
|
||||
|
@ -9,8 +9,7 @@ describe("updateOfferThroughputBeyondLimit", () => {
|
||||
});
|
||||
window.dataExplorer = {
|
||||
logConsoleData: jest.fn(),
|
||||
deleteInProgressConsoleDataWithId: jest.fn(),
|
||||
extensionEndpoint: jest.fn()
|
||||
deleteInProgressConsoleDataWithId: jest.fn()
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any;
|
||||
await updateOfferThroughputBeyondLimit({
|
||||
|
@ -28,8 +28,7 @@ export async function updateOfferThroughputBeyondLimit(request: UpdateOfferThrou
|
||||
`Requesting increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}`
|
||||
);
|
||||
|
||||
const explorer = window.dataExplorer;
|
||||
const url = `${explorer.extensionEndpoint()}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
||||
const url = `${configContext.BACKEND_ENDPOINT}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
|
||||
const response = await fetch(url, {
|
||||
|
@ -1,31 +1,25 @@
|
||||
jest.mock("../../../Juno/JunoClient");
|
||||
import { shallow } from "enzyme";
|
||||
import * as sinon from "sinon";
|
||||
import React from "react";
|
||||
import { CodeOfConductComponent, CodeOfConductComponentProps } from "./CodeOfConductComponent";
|
||||
import { IJunoResponse, JunoClient } from "../../../Juno/JunoClient";
|
||||
import { JunoClient } from "../../../Juno/JunoClient";
|
||||
import { HttpStatusCodes } from "../../../Common/Constants";
|
||||
|
||||
describe("CodeOfConductComponent", () => {
|
||||
let sandbox: sinon.SinonSandbox;
|
||||
let codeOfConductProps: CodeOfConductComponentProps;
|
||||
|
||||
beforeEach(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox.stub(JunoClient.prototype, "acceptCodeOfConduct").returns({
|
||||
const junoClient = new JunoClient(undefined);
|
||||
junoClient.acceptCodeOfConduct = jest.fn().mockReturnValue({
|
||||
status: HttpStatusCodes.OK,
|
||||
data: true
|
||||
} as IJunoResponse<boolean>);
|
||||
const junoClient = new JunoClient(undefined);
|
||||
});
|
||||
codeOfConductProps = {
|
||||
junoClient: junoClient,
|
||||
onAcceptCodeOfConduct: jest.fn()
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
@ -953,7 +953,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"validPartitionKeyValue": [Function],
|
||||
"visible": [Function],
|
||||
},
|
||||
"extensionEndpoint": [Function],
|
||||
"features": [Function],
|
||||
"flight": [Function],
|
||||
"graphStylingPane": GraphStylingPane {
|
||||
@ -2268,7 +2267,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"validPartitionKeyValue": [Function],
|
||||
"visible": [Function],
|
||||
},
|
||||
"extensionEndpoint": [Function],
|
||||
"features": [Function],
|
||||
"flight": [Function],
|
||||
"graphStylingPane": GraphStylingPane {
|
||||
@ -3596,7 +3594,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"validPartitionKeyValue": [Function],
|
||||
"visible": [Function],
|
||||
},
|
||||
"extensionEndpoint": [Function],
|
||||
"features": [Function],
|
||||
"flight": [Function],
|
||||
"graphStylingPane": GraphStylingPane {
|
||||
@ -4911,7 +4908,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"validPartitionKeyValue": [Function],
|
||||
"visible": [Function],
|
||||
},
|
||||
"extensionEndpoint": [Function],
|
||||
"features": [Function],
|
||||
"flight": [Function],
|
||||
"graphStylingPane": GraphStylingPane {
|
||||
|
@ -1,12 +1,11 @@
|
||||
jest.mock("../../Common/DocumentClientUtilityBase");
|
||||
jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
||||
jest.mock("../../Common/dataAccess/createCollection");
|
||||
import * as ko from "knockout";
|
||||
import * as sinon from "sinon";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import Q from "q";
|
||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||
import * as DocumentClientUtility from "../../Common/DocumentClientUtilityBase";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
@ -26,6 +25,10 @@ describe("ContainerSampleGenerator", () => {
|
||||
return explorerStub;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
(createDocument as jest.Mock).mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it("should insert documents for sql API account", async () => {
|
||||
const sampleCollectionId = "SampleCollection";
|
||||
const sampleDatabaseId = "SampleDB";
|
||||
@ -69,13 +72,10 @@ describe("ContainerSampleGenerator", () => {
|
||||
|
||||
await generator.createSampleContainerAsync();
|
||||
|
||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
||||
expect(createDocument).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should send gremlin queries for Graph API account", async () => {
|
||||
sinon.stub(GremlinClient.prototype, "initialize").callsFake(() => {});
|
||||
const executeStub = sinon.stub(GremlinClient.prototype, "execute").returns(Q.resolve());
|
||||
|
||||
updateUserContext({
|
||||
databaseAccount: {
|
||||
id: "foo",
|
||||
@ -121,9 +121,6 @@ describe("ContainerSampleGenerator", () => {
|
||||
generator.setData(sampleData);
|
||||
|
||||
await generator.createSampleContainerAsync();
|
||||
|
||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
||||
expect(executeStub.called).toBe(true);
|
||||
});
|
||||
|
||||
it("should not create any sample for Mongo API account", async () => {
|
||||
@ -133,7 +130,7 @@ describe("ContainerSampleGenerator", () => {
|
||||
explorerStub.defaultExperience = ko.observable<string>(experience);
|
||||
|
||||
// Rejects with error that contains experience
|
||||
await expect(ContainerSampleGenerator.createSampleGeneratorAsync(explorerStub)).rejects.toMatch(experience);
|
||||
expect(ContainerSampleGenerator.createSampleGeneratorAsync(explorerStub)).rejects.toMatch(experience);
|
||||
});
|
||||
|
||||
it("should not create any sample for Table API account", async () => {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import GraphTab from ".././Tabs/GraphTab";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import Explorer from "../Explorer";
|
||||
@ -96,9 +95,9 @@ export class ContainerSampleGenerator {
|
||||
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
||||
} else {
|
||||
// For SQL all queries are executed at the same time
|
||||
this.sampleDataFile.data.forEach(doc => {
|
||||
this.sampleDataFile.data.map(doc => {
|
||||
const subPromise = createDocument(collection, doc);
|
||||
subPromise.catch(reason => NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, reason));
|
||||
subPromise.catch(reason => NotificationConsoleUtils.logConsoleError(reason));
|
||||
promises.push(subPromise);
|
||||
});
|
||||
await Promise.all(promises);
|
||||
|
@ -140,7 +140,6 @@ export default class Explorer {
|
||||
public canSaveQueries: ko.Computed<boolean>;
|
||||
public features: ko.Observable<any>;
|
||||
public serverId: ko.Observable<string>;
|
||||
public extensionEndpoint: ko.Observable<string>;
|
||||
public armEndpoint: ko.Observable<string>;
|
||||
public isTryCosmosDBSubscription: ko.Observable<boolean>;
|
||||
public notificationsClient: NotificationsClientBase;
|
||||
@ -383,7 +382,6 @@ export default class Explorer {
|
||||
|
||||
this.features = ko.observable();
|
||||
this.serverId = ko.observable<string>();
|
||||
this.extensionEndpoint = ko.observable<string>(undefined);
|
||||
this.armEndpoint = ko.observable<string>(undefined);
|
||||
this.queriesClient = new QueriesClient(this);
|
||||
this.isTryCosmosDBSubscription = ko.observable<boolean>(false);
|
||||
@ -1912,9 +1910,8 @@ export default class Explorer {
|
||||
}
|
||||
this.features(inputs.features);
|
||||
this.serverId(inputs.serverId);
|
||||
this.extensionEndpoint(inputs.extensionEndpoint || "");
|
||||
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
|
||||
this.notificationsClient.setExtensionEndpoint(this.extensionEndpoint());
|
||||
this.notificationsClient.setExtensionEndpoint(configContext.BACKEND_ENDPOINT);
|
||||
this.databaseAccount(databaseAccount);
|
||||
this.subscriptionType(inputs.subscriptionType);
|
||||
this.quotaId(inputs.quotaId);
|
||||
@ -1930,6 +1927,7 @@ export default class Explorer {
|
||||
this._importExplorerConfigComplete = true;
|
||||
|
||||
updateConfigContext({
|
||||
BACKEND_ENDPOINT: inputs.extensionEndpoint || "",
|
||||
ARM_ENDPOINT: this.armEndpoint()
|
||||
});
|
||||
|
||||
@ -2633,7 +2631,7 @@ export default class Explorer {
|
||||
|
||||
const databaseAccount = this.databaseAccount();
|
||||
const databaseAccountLocation = databaseAccount && databaseAccount.location.toLowerCase();
|
||||
const disallowedLocationsUri = `${this.extensionEndpoint()}/api/disallowedLocations`;
|
||||
const disallowedLocationsUri = `${configContext.BACKEND_ENDPOINT}/api/disallowedLocations`;
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
try {
|
||||
const response = await fetch(disallowedLocationsUri, {
|
||||
@ -3130,8 +3128,10 @@ export default class Explorer {
|
||||
}
|
||||
|
||||
public async loadDatabaseOffers(): Promise<void> {
|
||||
this.databases()?.forEach(async (database: ViewModels.Database) => {
|
||||
await database.loadOffer();
|
||||
});
|
||||
await Promise.all(
|
||||
this.databases()?.map(async (database: ViewModels.Database) => {
|
||||
await database.loadOffer();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,11 @@ export class ArraysByKeyCache<T> {
|
||||
this.cache[key] = elements;
|
||||
|
||||
if (index < 0) {
|
||||
console.error("Inserting with negative index is not allowed by ArraysByCache");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that previous index is populated, if not, ignore
|
||||
if (index > elements.length) {
|
||||
console.error("Inserting non-contiguous element is not allowed by ArraysByCache");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,6 @@ export class GremlinClient {
|
||||
}
|
||||
|
||||
private static reportError(msg: string): void {
|
||||
console.error(msg);
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, msg);
|
||||
Logger.logError(msg, GremlinClient.LOG_AREA);
|
||||
}
|
||||
|
@ -136,7 +136,6 @@ export class GremlinSimpleClient {
|
||||
const data = typeof msg.data === "string" ? msg.data : new TextDecoder("utf-8").decode(msg.data);
|
||||
return JSON.parse(data);
|
||||
} catch (e) {
|
||||
console.error(e, msg);
|
||||
if (this.params.failureCallback) {
|
||||
this.params.failureCallback(
|
||||
null,
|
||||
|
@ -0,0 +1,6 @@
|
||||
/* eslint-disable */
|
||||
export class GremlinClient {
|
||||
constructor() {}
|
||||
initialize() {}
|
||||
execute() {}
|
||||
}
|
@ -22,6 +22,7 @@ import {
|
||||
updateDocument,
|
||||
createDocument
|
||||
} from "../../Common/DocumentClientUtilityBase";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
export interface CassandraTableKeys {
|
||||
partitionKeys: CassandraTableKey[];
|
||||
@ -307,7 +308,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
authType === AuthType.EncryptedToken
|
||||
? Constants.CassandraBackend.guestQueryApi
|
||||
: Constants.CassandraBackend.queryApi;
|
||||
$.ajax(`${collection.container.extensionEndpoint()}/${apiEndpoint}`, {
|
||||
$.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
||||
type: "POST",
|
||||
data: {
|
||||
accountName: collection && collection.container.databaseAccount && collection.container.databaseAccount().name,
|
||||
@ -558,7 +559,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
authType === AuthType.EncryptedToken
|
||||
? Constants.CassandraBackend.guestKeysApi
|
||||
: Constants.CassandraBackend.keysApi;
|
||||
let endpoint = `${collection.container.extensionEndpoint()}/${apiEndpoint}`;
|
||||
let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`;
|
||||
const deferred = Q.defer<CassandraTableKeys>();
|
||||
$.ajax(endpoint, {
|
||||
type: "POST",
|
||||
@ -613,7 +614,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
authType === AuthType.EncryptedToken
|
||||
? Constants.CassandraBackend.guestSchemaApi
|
||||
: Constants.CassandraBackend.schemaApi;
|
||||
let endpoint = `${collection.container.extensionEndpoint()}/${apiEndpoint}`;
|
||||
let endpoint = `${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`;
|
||||
const deferred = Q.defer<CassandraTableKey[]>();
|
||||
$.ajax(endpoint, {
|
||||
type: "POST",
|
||||
@ -667,7 +668,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
authType === AuthType.EncryptedToken
|
||||
? Constants.CassandraBackend.guestCreateOrDeleteApi
|
||||
: Constants.CassandraBackend.createOrDeleteApi;
|
||||
$.ajax(`${explorer.extensionEndpoint()}/${apiEndpoint}`, {
|
||||
$.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
||||
type: "POST",
|
||||
data: {
|
||||
accountName: explorer.databaseAccount() && explorer.databaseAccount().name,
|
||||
|
@ -13,6 +13,7 @@ import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils"
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
import Explorer from "../Explorer";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
export default class MongoShellTab extends TabsBase {
|
||||
public url: ko.Computed<string>;
|
||||
@ -30,9 +31,8 @@ export default class MongoShellTab extends TabsBase {
|
||||
const accountName = account && account.name;
|
||||
const mongoEndpoint = account && (account.properties.mongoEndpoint || account.properties.documentEndpoint);
|
||||
|
||||
this._runtimeEndpoint =
|
||||
window.dataExplorerPlatform == PlatformType.Hosted ? AuthHeadersUtil.extensionEndpoint : "";
|
||||
const extensionEndpoint: string = this._container.extensionEndpoint() || this._runtimeEndpoint || "";
|
||||
this._runtimeEndpoint = window.dataExplorerPlatform === PlatformType.Hosted ? configContext.BACKEND_ENDPOINT : "";
|
||||
const extensionEndpoint: string = configContext.BACKEND_ENDPOINT || this._runtimeEndpoint || "";
|
||||
let baseUrl = "/content/mongoshell/dist/";
|
||||
if (this._container.serverId() === "localhost") {
|
||||
baseUrl = "/content/mongoshell/";
|
||||
@ -108,7 +108,7 @@ export default class MongoShellTab extends TabsBase {
|
||||
) + Constants.MongoDBAccounts.defaultPort.toString();
|
||||
const databaseId = this.collection.databaseId;
|
||||
const collectionId = this.collection.id();
|
||||
const apiEndpoint = this._container.extensionEndpoint();
|
||||
const apiEndpoint = configContext.BACKEND_ENDPOINT;
|
||||
const encryptedAuthToken: string = userContext.accessToken;
|
||||
|
||||
shellIframe.contentWindow.postMessage(
|
||||
@ -125,7 +125,7 @@ export default class MongoShellTab extends TabsBase {
|
||||
apiEndpoint: apiEndpoint
|
||||
}
|
||||
},
|
||||
this._container.extensionEndpoint()
|
||||
configContext.BACKEND_ENDPOINT
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@ import { configContext } from "../../ConfigContext";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class AuthHeadersUtil {
|
||||
// TODO: Figure out a way to determine the extension endpoint and serverId at runtime
|
||||
public static extensionEndpoint: string = Constants.BackendEndpoints.productionPortal;
|
||||
public static serverId: string = Constants.ServerIds.productionPortal;
|
||||
|
||||
private static readonly _firstPartyAppId: string = "203f1145-856a-4232-83d4-a43568fba23d";
|
||||
@ -41,7 +39,7 @@ export default class AuthHeadersUtil {
|
||||
|
||||
public static getAccessInputMetadata(accessInput: string): Q.Promise<DataModels.AccessInputMetadata> {
|
||||
const deferred: Q.Deferred<DataModels.AccessInputMetadata> = Q.defer<DataModels.AccessInputMetadata>();
|
||||
const url: string = `${AuthHeadersUtil.extensionEndpoint}${Constants.ApiEndpoints.guestRuntimeProxy}/accessinputmetadata`;
|
||||
const url = `${configContext.BACKEND_ENDPOINT}${Constants.ApiEndpoints.guestRuntimeProxy}/accessinputmetadata`;
|
||||
const authType: string = (<any>window).authType;
|
||||
const headers: { [headerName: string]: string } = {};
|
||||
|
||||
@ -86,9 +84,7 @@ export default class AuthHeadersUtil {
|
||||
}
|
||||
|
||||
public static generateEncryptedToken(): Q.Promise<DataModels.GenerateTokenResponse> {
|
||||
const url: string = `${
|
||||
AuthHeadersUtil.extensionEndpoint
|
||||
}/api/tokens/generateToken${AuthHeadersUtil._generateResourceUrl()}`;
|
||||
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + AuthHeadersUtil._generateResourceUrl();
|
||||
const explorer = window.dataExplorer;
|
||||
const headers: any = { authorization: userContext.authorizationToken };
|
||||
headers[Constants.HttpHeaders.getReadOnlyKey] = !explorer.hasWriteAccess();
|
||||
@ -109,7 +105,7 @@ export default class AuthHeadersUtil {
|
||||
return Q.reject("None or empty connection string specified");
|
||||
}
|
||||
|
||||
const url: string = `${AuthHeadersUtil.extensionEndpoint}/api/guest/tokens/generateToken`;
|
||||
const url = configContext.BACKEND_ENDPOINT + "/api/guest/tokens/generateToken";
|
||||
const headers: any = {};
|
||||
headers[Constants.HttpHeaders.connectionString] = connectionString;
|
||||
|
||||
|
@ -24,12 +24,12 @@ import { SubscriptionUtilMappings } from "../../Shared/Constants";
|
||||
import "../../Explorer/Tables/DataTable/DataTableBindingManager";
|
||||
import Explorer from "../../Explorer/Explorer";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
|
||||
export default class Main {
|
||||
private static _databaseAccountId: string;
|
||||
private static _encryptedToken: string;
|
||||
private static _accessInputMetadata: AccessInputMetadata;
|
||||
private static _defaultSubscriptionType: ViewModels.SubscriptionType = ViewModels.SubscriptionType.Free;
|
||||
private static _features: { [key: string]: string };
|
||||
// For AAD, Need to post message to hosted frame to do the auth
|
||||
// Use local deferred variable as work around until we find better solution
|
||||
@ -315,7 +315,7 @@ export default class Main {
|
||||
csmEndpoint: undefined,
|
||||
dnsSuffix: null,
|
||||
serverId: serverId,
|
||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
||||
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||
quotaId: undefined,
|
||||
addCollectionDefaultFlight: explorer.flight(),
|
||||
@ -335,7 +335,7 @@ export default class Main {
|
||||
csmEndpoint: undefined,
|
||||
dnsSuffix: null,
|
||||
serverId: serverId,
|
||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
||||
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||
quotaId: undefined,
|
||||
addCollectionDefaultFlight: explorer.flight(),
|
||||
@ -365,7 +365,7 @@ export default class Main {
|
||||
csmEndpoint: undefined,
|
||||
dnsSuffix: null,
|
||||
serverId: serverId,
|
||||
extensionEndpoint: AuthHeadersUtil.extensionEndpoint,
|
||||
extensionEndpoint: configContext.BACKEND_ENDPOINT,
|
||||
subscriptionType: CollectionCreation.DefaultSubscriptionType,
|
||||
quotaId: undefined,
|
||||
addCollectionDefaultFlight: explorer.flight(),
|
||||
@ -453,11 +453,6 @@ export default class Main {
|
||||
return connectionString && connectionString.includes("type=resource");
|
||||
}
|
||||
|
||||
private static _getSubscriptionTypeFromQuotaId(quotaId: string): ViewModels.SubscriptionType {
|
||||
const subscriptionType: ViewModels.SubscriptionType = SubscriptionUtilMappings.SubscriptionTypeMap[quotaId];
|
||||
return subscriptionType || Main._defaultSubscriptionType;
|
||||
}
|
||||
|
||||
private static _renewExplorerAccessWithResourceToken = (
|
||||
explorer: Explorer,
|
||||
connectionString: string
|
||||
|
@ -7,7 +7,7 @@ import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
|
||||
import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
import { TerminalQueryParams } from "../Common/Constants";
|
||||
import { HttpHeaders, TerminalQueryParams } from "../Common/Constants";
|
||||
|
||||
const getUrlVars = (): { [key: string]: string } => {
|
||||
const vars: { [key: string]: string } = {};
|
||||
@ -20,16 +20,20 @@ const getUrlVars = (): { [key: string]: string } => {
|
||||
|
||||
const createServerSettings = (urlVars: { [key: string]: string }): ServerConnection.ISettings => {
|
||||
let body: BodyInit;
|
||||
let headers: HeadersInit;
|
||||
if (urlVars.hasOwnProperty(TerminalQueryParams.TerminalEndpoint)) {
|
||||
body = JSON.stringify({
|
||||
endpoint: urlVars[TerminalQueryParams.TerminalEndpoint]
|
||||
});
|
||||
headers = {
|
||||
[HttpHeaders.contentType]: "application/json"
|
||||
};
|
||||
}
|
||||
|
||||
const server = urlVars[TerminalQueryParams.Server];
|
||||
let options: Partial<ServerConnection.ISettings> = {
|
||||
baseUrl: server,
|
||||
init: { body },
|
||||
init: { body, headers },
|
||||
fetch: window.parent.fetch
|
||||
};
|
||||
if (urlVars.hasOwnProperty(TerminalQueryParams.Token)) {
|
||||
@ -37,7 +41,7 @@ const createServerSettings = (urlVars: { [key: string]: string }): ServerConnect
|
||||
baseUrl: server,
|
||||
token: urlVars[TerminalQueryParams.Token],
|
||||
appendToken: true,
|
||||
init: { body },
|
||||
init: { body, headers },
|
||||
fetch: window.parent.fetch
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user