@thoughtspot/visual-embed-sdk 1.27.0-alpha.2 → 1.27.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/package.json +1 -1
- package/cjs/src/embed/liveboard.d.ts +7 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +4 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +2 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/types.d.ts +36 -4
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +32 -0
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +2 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/dist/src/embed/liveboard.d.ts +7 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/types.d.ts +36 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +38 -3
- package/dist/tsembed-react.js +38 -3
- package/dist/tsembed.es.js +38 -3
- package/dist/tsembed.js +38 -3
- package/dist/visual-embed-sdk-react-full.d.ts +43 -4
- package/dist/visual-embed-sdk-react.d.ts +43 -4
- package/dist/visual-embed-sdk.d.ts +43 -4
- package/lib/package.json +1 -1
- package/lib/src/embed/liveboard.d.ts +7 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +4 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +2 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/types.d.ts +36 -4
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +32 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +2 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +43 -4
- package/package.json +1 -1
- package/src/embed/liveboard.spec.ts +2 -1
- package/src/embed/liveboard.ts +11 -0
- package/src/types.ts +33 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +2 -0
- package/src/utils/graphql/answerService/answerService.ts +3 -1
- package/cjs/.DS_Store +0 -0
- package/cjs/src/.DS_Store +0 -0
- package/cjs/src/utils/answerService.d.ts +0 -10
- package/cjs/src/utils/answerService.d.ts.map +0 -1
- package/cjs/src/utils/answerService.js +0 -61
- package/cjs/src/utils/answerService.js.map +0 -1
- package/cjs/src/utils/answerService.spec.d.ts +0 -2
- package/cjs/src/utils/answerService.spec.d.ts.map +0 -1
- package/cjs/src/utils/answerService.spec.js +0 -31
- package/cjs/src/utils/answerService.spec.js.map +0 -1
- package/cjs/src/utils/authService.d.ts +0 -37
- package/cjs/src/utils/authService.d.ts.map +0 -1
- package/cjs/src/utils/authService.js +0 -106
- package/cjs/src/utils/authService.js.map +0 -1
- package/cjs/src/utils/authService.spec.d.ts +0 -2
- package/cjs/src/utils/authService.spec.d.ts.map +0 -1
- package/cjs/src/utils/authService.spec.js +0 -72
- package/cjs/src/utils/authService.spec.js.map +0 -1
- package/dist/src/utils/answerService.d.ts +0 -10
- package/dist/src/utils/answerService.d.ts.map +0 -1
- package/dist/src/utils/answerService.spec.d.ts +0 -2
- package/dist/src/utils/answerService.spec.d.ts.map +0 -1
- package/dist/src/utils/authService.d.ts +0 -37
- package/dist/src/utils/authService.d.ts.map +0 -1
- package/dist/src/utils/authService.spec.d.ts +0 -2
- package/dist/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/.DS_Store +0 -0
- package/lib/src/.DS_Store +0 -0
- package/lib/src/utils/answerService.d.ts +0 -10
- package/lib/src/utils/answerService.d.ts.map +0 -1
- package/lib/src/utils/answerService.js +0 -57
- package/lib/src/utils/answerService.js.map +0 -1
- package/lib/src/utils/answerService.spec.d.ts +0 -2
- package/lib/src/utils/answerService.spec.d.ts.map +0 -1
- package/lib/src/utils/answerService.spec.js +0 -29
- package/lib/src/utils/answerService.spec.js.map +0 -1
- package/lib/src/utils/authService.d.ts +0 -37
- package/lib/src/utils/authService.d.ts.map +0 -1
- package/lib/src/utils/authService.js +0 -97
- package/lib/src/utils/authService.js.map +0 -1
- package/lib/src/utils/authService.spec.d.ts +0 -2
- package/lib/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/src/utils/authService.spec.js +0 -70
- package/lib/src/utils/authService.spec.js.map +0 -1
- package/src/.DS_Store +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchLogoutService = exports.fetchBasicAuthService = exports.fetchAuthPostService = exports.fetchAuthService = exports.fetchAuthTokenService = exports.fetchSessionInfoService = void 0;
|
|
4
|
-
// eslint-disable-next-line import/no-cycle
|
|
5
|
-
const auth_1 = require("../auth");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param url
|
|
9
|
-
* @param options
|
|
10
|
-
*/
|
|
11
|
-
function failureLoggedFetch(url, options = {}) {
|
|
12
|
-
return fetch(url, options).then(async (r) => {
|
|
13
|
-
var _a;
|
|
14
|
-
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
15
|
-
console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
16
|
-
}
|
|
17
|
-
return r;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param authVerificationUrl
|
|
23
|
-
*/
|
|
24
|
-
function fetchSessionInfoService(authVerificationUrl) {
|
|
25
|
-
return failureLoggedFetch(authVerificationUrl, {
|
|
26
|
-
credentials: 'include',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
exports.fetchSessionInfoService = fetchSessionInfoService;
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param authEndpoint
|
|
33
|
-
*/
|
|
34
|
-
async function fetchAuthTokenService(authEndpoint) {
|
|
35
|
-
return fetch(authEndpoint);
|
|
36
|
-
}
|
|
37
|
-
exports.fetchAuthTokenService = fetchAuthTokenService;
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param thoughtSpotHost
|
|
41
|
-
* @param username
|
|
42
|
-
* @param authToken
|
|
43
|
-
*/
|
|
44
|
-
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
45
|
-
return failureLoggedFetch(`${thoughtSpotHost}${auth_1.EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
46
|
-
credentials: 'include',
|
|
47
|
-
// We do not want to follow the redirect, as it starts giving a CORS
|
|
48
|
-
// error
|
|
49
|
-
redirect: 'manual',
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.fetchAuthService = fetchAuthService;
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @param thoughtSpotHost
|
|
56
|
-
* @param username
|
|
57
|
-
* @param authToken
|
|
58
|
-
*/
|
|
59
|
-
async function fetchAuthPostService(thoughtSpotHost, username, authToken) {
|
|
60
|
-
return failureLoggedFetch(`${thoughtSpotHost}${auth_1.EndPoints.TOKEN_LOGIN}`, {
|
|
61
|
-
method: 'POST',
|
|
62
|
-
headers: {
|
|
63
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
64
|
-
'x-requested-by': 'ThoughtSpot',
|
|
65
|
-
},
|
|
66
|
-
body: `username=${encodeURIComponent(username)}&auth_token=${encodeURIComponent(authToken)}`,
|
|
67
|
-
credentials: 'include',
|
|
68
|
-
// We do not want to follow the redirect, as it starts giving a CORS
|
|
69
|
-
// error
|
|
70
|
-
redirect: 'manual',
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.fetchAuthPostService = fetchAuthPostService;
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @param thoughtSpotHost
|
|
77
|
-
* @param username
|
|
78
|
-
* @param password
|
|
79
|
-
*/
|
|
80
|
-
async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
81
|
-
return failureLoggedFetch(`${thoughtSpotHost}${auth_1.EndPoints.BASIC_LOGIN}`, {
|
|
82
|
-
method: 'POST',
|
|
83
|
-
headers: {
|
|
84
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
85
|
-
'x-requested-by': 'ThoughtSpot',
|
|
86
|
-
},
|
|
87
|
-
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
88
|
-
credentials: 'include',
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
exports.fetchBasicAuthService = fetchBasicAuthService;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param thoughtSpotHost
|
|
95
|
-
*/
|
|
96
|
-
async function fetchLogoutService(thoughtSpotHost) {
|
|
97
|
-
return failureLoggedFetch(`${thoughtSpotHost}${auth_1.EndPoints.LOGOUT}`, {
|
|
98
|
-
credentials: 'include',
|
|
99
|
-
method: 'POST',
|
|
100
|
-
headers: {
|
|
101
|
-
'x-requested-by': 'ThoughtSpot',
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
exports.fetchLogoutService = fetchLogoutService;
|
|
106
|
-
//# sourceMappingURL=authService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.js","sourceRoot":"","sources":["../../../src/utils/authService.ts"],"names":[],"mappings":";;;AAAA,2CAA2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QACd,OAAO,EAAE;YACL,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,aAAa;SAClC;QACD,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,eAAe,kBAAkB,CAC3E,SAAS,CACZ,EAAE;QACH,WAAW,EAAE,SAAS;QACtB,oEAAoE;QACpE,QAAQ;QACR,QAAQ,EAAE,QAAQ;KACrB,CAAC,CAAC;AACP,CAAC;AAnBD,oDAmBC;AAED;;;;;GAKG;AACI,KAAK,UAAU,qBAAqB,CACvC,eAAuB,EACvB,QAAgB,EAChB,QAAgB;IAEhB,OAAO,kBAAkB,CAAC,GAAG,eAAe,GAAG,gBAAS,CAAC,WAAW,EAAE,EAAE;QACpE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,aAAa;SAClC;QACD,IAAI,EAAE,YAAY,kBAAkB,CAAC,QAAQ,CAAC,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE;QACzF,WAAW,EAAE,SAAS;KACzB,CAAC,CAAC;AACP,CAAC;AAdD,sDAcC;AAED;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,eAAuB;IAC5D,OAAO,kBAAkB,CAAC,GAAG,eAAe,GAAG,gBAAS,CAAC,MAAM,EAAE,EAAE;QAC/D,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,gBAAgB,EAAE,aAAa;SAClC;KACJ,CAAC,CAAC;AACP,CAAC;AARD,gDAQC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.spec.d.ts","sourceRoot":"","sources":["../../../src/utils/authService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const authService_1 = require("./authService");
|
|
4
|
-
const auth_1 = require("../auth");
|
|
5
|
-
const thoughtSpotHost = 'http://10.79.135.124:3000';
|
|
6
|
-
const authVerificationUrl = 'http://localhost:3000';
|
|
7
|
-
const authEndpoint = '';
|
|
8
|
-
const username = 'tsuser';
|
|
9
|
-
const password = 'password';
|
|
10
|
-
const authToken = 'token';
|
|
11
|
-
describe('Unit test for authService', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
global.fetch = window.fetch;
|
|
14
|
-
});
|
|
15
|
-
test('fetchSessionInfoService', async () => {
|
|
16
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
17
|
-
json: () => ({ success: true }),
|
|
18
|
-
status: 200,
|
|
19
|
-
ok: true,
|
|
20
|
-
}));
|
|
21
|
-
const response = await (0, authService_1.fetchSessionInfoService)(authVerificationUrl);
|
|
22
|
-
expect(response.status).toBe(200);
|
|
23
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
24
|
-
});
|
|
25
|
-
test('fetchAuthTokenService', async () => {
|
|
26
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
27
|
-
text: () => ({ success: true }),
|
|
28
|
-
ok: true,
|
|
29
|
-
}));
|
|
30
|
-
const response = await (0, authService_1.fetchAuthTokenService)(authEndpoint);
|
|
31
|
-
expect(response.text()).toStrictEqual({ success: true });
|
|
32
|
-
expect(fetch).toBeCalled();
|
|
33
|
-
});
|
|
34
|
-
test('fetchAuthService', async () => {
|
|
35
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
36
|
-
await (0, authService_1.fetchAuthService)(thoughtSpotHost, username, authToken);
|
|
37
|
-
expect(fetch).toBeCalledWith(`${thoughtSpotHost}${auth_1.EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
38
|
-
credentials: 'include',
|
|
39
|
-
redirect: 'manual',
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
test('fetchAuthPostService', async () => {
|
|
43
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
44
|
-
await (0, authService_1.fetchAuthPostService)(thoughtSpotHost, username, authToken);
|
|
45
|
-
expect(fetch).toBeCalledWith(`${thoughtSpotHost}${auth_1.EndPoints.TOKEN_LOGIN}`, {
|
|
46
|
-
method: 'POST',
|
|
47
|
-
credentials: 'include',
|
|
48
|
-
redirect: 'manual',
|
|
49
|
-
body: 'username=tsuser&auth_token=token',
|
|
50
|
-
headers: {
|
|
51
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
52
|
-
'x-requested-by': 'ThoughtSpot',
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
test('fetchBasicAuthService called with manual redirect', async () => {
|
|
57
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
58
|
-
await (0, authService_1.fetchBasicAuthService)(thoughtSpotHost, username, password);
|
|
59
|
-
expect(fetch).toBeCalled();
|
|
60
|
-
});
|
|
61
|
-
test('log error on API failures', async () => {
|
|
62
|
-
jest.spyOn(global.console, 'error').mockImplementation(() => undefined);
|
|
63
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
64
|
-
text: () => Promise.resolve('error'),
|
|
65
|
-
status: 500,
|
|
66
|
-
ok: false,
|
|
67
|
-
}));
|
|
68
|
-
await (0, authService_1.fetchSessionInfoService)(authVerificationUrl);
|
|
69
|
-
expect(global.console.error).toHaveBeenCalledWith('Failure', 'error');
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
//# sourceMappingURL=authService.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.spec.js","sourceRoot":"","sources":["../../../src/utils/authService.spec.ts"],"names":[],"mappings":";;AAAA,+CAMuB;AACvB,kCAAoC;AAEpC,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAEpD,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AACpD,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,QAAQ,GAAG,QAAQ,CAAC;AA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AAI,EAAE;QACjE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3E,MAAM,IAAA,mCAAqB,EAAC,eAAe,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;YACzC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACpC,MAAM,EAAE,GAAG;YACX,EAAE,EAAE,KAAK;SACZ,CAAC,CAAC,CAAC;QACJ,MAAM,IAAA,qCAAuB,EAAC,mBAAmB,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SessionInterface } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param session
|
|
5
|
-
* @param query
|
|
6
|
-
* @param operation
|
|
7
|
-
* @param thoughtSpotHost
|
|
8
|
-
*/
|
|
9
|
-
export declare function getAnswerServiceInstance(session: SessionInterface, query: string, operation: string, thoughtSpotHost: string): any;
|
|
10
|
-
//# sourceMappingURL=answerService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.d.ts","sourceRoot":"","sources":["answerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiB,MAAM,UAAU,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACxB,GAAG,CAgDL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.spec.d.ts","sourceRoot":"","sources":["answerService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param authVerificationUrl
|
|
4
|
-
*/
|
|
5
|
-
export declare function fetchSessionInfoService(authVerificationUrl: string): Promise<any>;
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param authEndpoint
|
|
9
|
-
*/
|
|
10
|
-
export declare function fetchAuthTokenService(authEndpoint: string): Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param thoughtSpotHost
|
|
14
|
-
* @param username
|
|
15
|
-
* @param authToken
|
|
16
|
-
*/
|
|
17
|
-
export declare function fetchAuthService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param thoughtSpotHost
|
|
21
|
-
* @param username
|
|
22
|
-
* @param authToken
|
|
23
|
-
*/
|
|
24
|
-
export declare function fetchAuthPostService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param thoughtSpotHost
|
|
28
|
-
* @param username
|
|
29
|
-
* @param password
|
|
30
|
-
*/
|
|
31
|
-
export declare function fetchBasicAuthService(thoughtSpotHost: string, username: string, password: string): Promise<any>;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param thoughtSpotHost
|
|
35
|
-
*/
|
|
36
|
-
export declare function fetchLogoutService(thoughtSpotHost: string): Promise<any>;
|
|
37
|
-
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["authService.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAIjF;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAE9E;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAClC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACtC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,CAed;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACvC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAQ9E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.spec.d.ts","sourceRoot":"","sources":["authService.spec.ts"],"names":[],"mappings":""}
|
package/lib/.DS_Store
DELETED
|
Binary file
|
package/lib/src/.DS_Store
DELETED
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SessionInterface } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param session
|
|
5
|
-
* @param query
|
|
6
|
-
* @param operation
|
|
7
|
-
* @param thoughtSpotHost
|
|
8
|
-
*/
|
|
9
|
-
export declare function getAnswerServiceInstance(session: SessionInterface, query: string, operation: string, thoughtSpotHost: string): any;
|
|
10
|
-
//# sourceMappingURL=answerService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.d.ts","sourceRoot":"","sources":["../../../src/utils/answerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiB,MAAM,UAAU,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACxB,GAAG,CAgDL"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { OperationType } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param session
|
|
5
|
-
* @param query
|
|
6
|
-
* @param operation
|
|
7
|
-
* @param thoughtSpotHost
|
|
8
|
-
*/
|
|
9
|
-
export function getAnswerServiceInstance(session, query, operation, thoughtSpotHost) {
|
|
10
|
-
let variable;
|
|
11
|
-
const fetchQuery = async (variables) => {
|
|
12
|
-
try {
|
|
13
|
-
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operation}`, {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'content-type': 'application/json;charset=UTF-8',
|
|
17
|
-
'x-requested-by': 'ThoughtSpot',
|
|
18
|
-
accept: '*/*',
|
|
19
|
-
'accept-language': 'en-us',
|
|
20
|
-
},
|
|
21
|
-
body: JSON.stringify({
|
|
22
|
-
operationName: operation,
|
|
23
|
-
query,
|
|
24
|
-
variables,
|
|
25
|
-
}),
|
|
26
|
-
credentials: 'include',
|
|
27
|
-
});
|
|
28
|
-
const result = await response.json();
|
|
29
|
-
return result.data;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
return error;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const fetchData = (offset, batchSize) => {
|
|
36
|
-
if (operation === OperationType.GetChartWithData) {
|
|
37
|
-
variable = { batchSize, offset: offset * batchSize };
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
variable = {
|
|
41
|
-
dataPaginationParams: {
|
|
42
|
-
isClientPaginated: true,
|
|
43
|
-
offset: offset * batchSize,
|
|
44
|
-
size: batchSize,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return fetchQuery({
|
|
49
|
-
session,
|
|
50
|
-
...variable,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
fetchData,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=answerService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.js","sourceRoot":"","sources":["../../../src/utils/answerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACpC,OAAyB,EACzB,KAAa,EACb,SAAiB,EACjB,eAAuB;IAEvB,IAAI,QAAa,CAAC;IAElB,MAAM,UAAU,GAAG,KAAK,EAAE,SAAc,EAAE,EAAE;QACxC,IAAI;YACA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,eAAe,cAAc,SAAS,EAAE,EAAE;gBACtE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACL,cAAc,EAAE,gCAAgC;oBAChD,gBAAgB,EAAE,aAAa;oBAC/B,MAAM,EAAE,KAAK;oBACb,iBAAiB,EAAE,OAAO;iBAC7B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACjB,aAAa,EAAE,SAAS;oBACxB,KAAK;oBACL,SAAS;iBACZ,CAAC;gBACF,WAAW,EAAE,SAAS;aACzB,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAE,EAAE;QACpD,IAAI,SAAS,KAAK,aAAa,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;SACxD;aAAM;YACH,QAAQ,GAAG;gBACP,oBAAoB,EAAE;oBAClB,iBAAiB,EAAE,IAAI;oBACvB,MAAM,EAAE,MAAM,GAAG,SAAS;oBAC1B,IAAI,EAAE,SAAS;iBAClB;aACJ,CAAC;SACL;QACD,OAAO,UAAU,CAAC;YACd,OAAO;YACP,GAAG,QAAQ;SACd,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO;QACH,SAAS;KACZ,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.spec.d.ts","sourceRoot":"","sources":["../../../src/utils/answerService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getAnswerServiceInstance } from './answerService';
|
|
2
|
-
describe('Unit test for getAnswerServiceInstance', () => {
|
|
3
|
-
const session = {
|
|
4
|
-
sessionId: '',
|
|
5
|
-
genNo: 2,
|
|
6
|
-
acSession: { sessionId: '', genNo: 1 },
|
|
7
|
-
};
|
|
8
|
-
const query = '';
|
|
9
|
-
const thoughtSpotHost = 'http://10.79.135.124:3000';
|
|
10
|
-
test('fetchData, when api giving answer data', async () => {
|
|
11
|
-
const mockAnswerResponse = { data: {} };
|
|
12
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
13
|
-
json: () => mockAnswerResponse,
|
|
14
|
-
}));
|
|
15
|
-
const answerService = getAnswerServiceInstance(session, query, 'GetTableWithHeadlineData', thoughtSpotHost);
|
|
16
|
-
const answerData = await answerService.fetchData(1, 500);
|
|
17
|
-
expect(answerData).toStrictEqual(mockAnswerResponse.data);
|
|
18
|
-
expect(answerData).not.toBeInstanceOf(Error);
|
|
19
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
20
|
-
});
|
|
21
|
-
test('fetchData, when api giving error', async () => {
|
|
22
|
-
global.fetch = jest.fn(() => Promise.reject(new Error('failure')));
|
|
23
|
-
const answerService = getAnswerServiceInstance(session, query, 'GetChartWithData', thoughtSpotHost);
|
|
24
|
-
const answerData = await answerService.fetchData(1, 500);
|
|
25
|
-
expect(answerData).toBeInstanceOf(Error);
|
|
26
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=answerService.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answerService.spec.js","sourceRoot":"","sources":["../../../src/utils/answerService.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACpD,MAAM,OAAO,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;KACzC,CAAC;IACF,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,MAAM,eAAe,GAAG,2BAA2B,CAAC;IAEpD,IAAI,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,E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essionInfoService(authVerificationUrl: string): Promise<any>;
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param authEndpoint
|
|
9
|
-
*/
|
|
10
|
-
export declare function fetchAuthTokenService(authEndpoint: string): Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param thoughtSpotHost
|
|
14
|
-
* @param username
|
|
15
|
-
* @param authToken
|
|
16
|
-
*/
|
|
17
|
-
export declare function fetchAuthService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param thoughtSpotHost
|
|
21
|
-
* @param username
|
|
22
|
-
* @param authToken
|
|
23
|
-
*/
|
|
24
|
-
export declare function fetchAuthPostService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param thoughtSpotHost
|
|
28
|
-
* @param username
|
|
29
|
-
* @param password
|
|
30
|
-
*/
|
|
31
|
-
export declare function fetchBasicAuthService(thoughtSpotHost: string, username: string, password: string): Promise<any>;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param thoughtSpotHost
|
|
35
|
-
*/
|
|
36
|
-
export declare function fetchLogoutService(thoughtSpotHost: string): Promise<any>;
|
|
37
|
-
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../src/utils/authService.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAIjF;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAE9E;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAClC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACtC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,CAed;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACvC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAQ9E"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-cycle
|
|
2
|
-
import { EndPoints } from '../auth';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param url
|
|
6
|
-
* @param options
|
|
7
|
-
*/
|
|
8
|
-
function failureLoggedFetch(url, options = {}) {
|
|
9
|
-
return fetch(url, options).then(async (r) => {
|
|
10
|
-
var _a;
|
|
11
|
-
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
12
|
-
console.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
13
|
-
}
|
|
14
|
-
return r;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param authVerificationUrl
|
|
20
|
-
*/
|
|
21
|
-
export function fetchSessionInfoService(authVerificationUrl) {
|
|
22
|
-
return failureLoggedFetch(authVerificationUrl, {
|
|
23
|
-
credentials: 'include',
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param authEndpoint
|
|
29
|
-
*/
|
|
30
|
-
export async function fetchAuthTokenService(authEndpoint) {
|
|
31
|
-
return fetch(authEndpoint);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param thoughtSpotHost
|
|
36
|
-
* @param username
|
|
37
|
-
* @param authToken
|
|
38
|
-
*/
|
|
39
|
-
export async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
40
|
-
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
41
|
-
credentials: 'include',
|
|
42
|
-
// We do not want to follow the redirect, as it starts giving a CORS
|
|
43
|
-
// error
|
|
44
|
-
redirect: 'manual',
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @param thoughtSpotHost
|
|
50
|
-
* @param username
|
|
51
|
-
* @param authToken
|
|
52
|
-
*/
|
|
53
|
-
export async function fetchAuthPostService(thoughtSpotHost, username, authToken) {
|
|
54
|
-
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
|
|
55
|
-
method: 'POST',
|
|
56
|
-
headers: {
|
|
57
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
58
|
-
'x-requested-by': 'ThoughtSpot',
|
|
59
|
-
},
|
|
60
|
-
body: `username=${encodeURIComponent(username)}&auth_token=${encodeURIComponent(authToken)}`,
|
|
61
|
-
credentials: 'include',
|
|
62
|
-
// We do not want to follow the redirect, as it starts giving a CORS
|
|
63
|
-
// error
|
|
64
|
-
redirect: 'manual',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* @param thoughtSpotHost
|
|
70
|
-
* @param username
|
|
71
|
-
* @param password
|
|
72
|
-
*/
|
|
73
|
-
export async function fetchBasicAuthService(thoughtSpotHost, username, password) {
|
|
74
|
-
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
headers: {
|
|
77
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
78
|
-
'x-requested-by': 'ThoughtSpot',
|
|
79
|
-
},
|
|
80
|
-
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
|
|
81
|
-
credentials: 'include',
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param thoughtSpotHost
|
|
87
|
-
*/
|
|
88
|
-
export async function fetchLogoutService(thoughtSpotHost) {
|
|
89
|
-
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
90
|
-
credentials: 'include',
|
|
91
|
-
method: 'POST',
|
|
92
|
-
headers: {
|
|
93
|
-
'x-requested-by': 'ThoughtSpot',
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=authService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.js","sourceRoot":"","sources":["../../../src/utils/authService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,GAAW,EAAE,UAAuB,EAAE;IAC9D,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;;QACxC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC7D,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAA,MAAA,CAAC,CAAC,IAAI,iDAAI,CAAA,CAAC,CAAC;SAC9C;QACD,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,mBAA2B;IAC/D,OAAO,kBAAkB,CAAC,mBAAmB,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BAAkB,CAAC,QAAQ,CAAC,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE;QACzF,WAAW,EAAE,SAAS;KACzB,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,eAAuB;IAC5D,OAAO,kBAAkB,CAAC,GAAG,eAAe,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE;QAC/D,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,gBAAgB,EAAE,aAAa;SAClC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.spec.d.ts","sourceRoot":"","sources":["../../../src/utils/authService.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { fetchSessionInfoService, fetchAuthTokenService, fetchAuthService, fetchBasicAuthService, fetchAuthPostService, } from './authService';
|
|
2
|
-
import { EndPoints } from '../auth';
|
|
3
|
-
const thoughtSpotHost = 'http://10.79.135.124:3000';
|
|
4
|
-
const authVerificationUrl = 'http://localhost:3000';
|
|
5
|
-
const authEndpoint = '';
|
|
6
|
-
const username = 'tsuser';
|
|
7
|
-
const password = 'password';
|
|
8
|
-
const authToken = 'token';
|
|
9
|
-
describe('Unit test for authService', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
global.fetch = window.fetch;
|
|
12
|
-
});
|
|
13
|
-
test('fetchSessionInfoService', async () => {
|
|
14
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
15
|
-
json: () => ({ success: true }),
|
|
16
|
-
status: 200,
|
|
17
|
-
ok: true,
|
|
18
|
-
}));
|
|
19
|
-
const response = await fetchSessionInfoService(authVerificationUrl);
|
|
20
|
-
expect(response.status).toBe(200);
|
|
21
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
22
|
-
});
|
|
23
|
-
test('fetchAuthTokenService', async () => {
|
|
24
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
25
|
-
text: () => ({ success: true }),
|
|
26
|
-
ok: true,
|
|
27
|
-
}));
|
|
28
|
-
const response = await fetchAuthTokenService(authEndpoint);
|
|
29
|
-
expect(response.text()).toStrictEqual({ success: true });
|
|
30
|
-
expect(fetch).toBeCalled();
|
|
31
|
-
});
|
|
32
|
-
test('fetchAuthService', async () => {
|
|
33
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
34
|
-
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
35
|
-
expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`, {
|
|
36
|
-
credentials: 'include',
|
|
37
|
-
redirect: 'manual',
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
test('fetchAuthPostService', async () => {
|
|
41
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
42
|
-
await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
43
|
-
expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
credentials: 'include',
|
|
46
|
-
redirect: 'manual',
|
|
47
|
-
body: 'username=tsuser&auth_token=token',
|
|
48
|
-
headers: {
|
|
49
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
50
|
-
'x-requested-by': 'ThoughtSpot',
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
test('fetchBasicAuthService called with manual redirect', async () => {
|
|
55
|
-
global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
|
|
56
|
-
await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
57
|
-
expect(fetch).toBeCalled();
|
|
58
|
-
});
|
|
59
|
-
test('log error on API failures', async () => {
|
|
60
|
-
jest.spyOn(global.console, 'error').mockImplementation(() => undefined);
|
|
61
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
62
|
-
text: () => Promise.resolve('error'),
|
|
63
|
-
status: 500,
|
|
64
|
-
ok: false,
|
|
65
|
-
}));
|
|
66
|
-
await fetchSessionInfoService(authVerificationUrl);
|
|
67
|
-
expect(global.console.error).toHaveBeenCalledWith('Failure', 'error');
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=authService.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authService.spec.js","sourceRoot":"","sources":["../../../src/utils/authService.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAEpD,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AACpD,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAC1B,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACvC,UAAU,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;YACzC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC/B,MAAM,EAAE,GAAG;YACX,EAAE,EAAE,IAAI;SACX,CAAC,CAAC,CAAC;QACJ,MAAM,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