@webex/test-users 3.0.0-beta.13 → 3.0.0-beta.15
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/README.md +3 -3
- package/dist/index.js +31 -19
- package/dist/index.js.map +1 -1
- package/dist/whistler.js +24 -10
- package/dist/whistler.js.map +1 -1
- package/package.json +4 -4
- package/src/index.js +65 -52
- package/src/whistler.js +69 -57
- package/test/integration/spec/index.js +76 -64
- package/test/integration/spec/whistler.js +4 -5
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ npm install --save @webex/test-users
|
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
_Note: This package is NODE only, not for browser usage_
|
|
25
25
|
|
|
26
26
|
With the test users library, you can create and remove Webex test users:
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ createTestUser({displayName: 'Test User'}).then((myTestUser) => {
|
|
|
32
32
|
// Do something amazing with myTestUser
|
|
33
33
|
|
|
34
34
|
// When done, remove the test user
|
|
35
|
-
removeTestUser(myTestUser)
|
|
35
|
+
removeTestUser(myTestUser);
|
|
36
36
|
});
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -68,7 +68,7 @@ createTestUser({whistler: true}).then((myTestUser) => {
|
|
|
68
68
|
// Do something amazing with myTestUser
|
|
69
69
|
|
|
70
70
|
// When done, remove the test user
|
|
71
|
-
removeTestUser(myTestUser)
|
|
71
|
+
removeTestUser(myTestUser);
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
6
6
|
|
|
7
|
-
var _Object$
|
|
7
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
8
8
|
|
|
9
9
|
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
10
|
|
|
11
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
12
|
+
|
|
13
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
14
|
+
|
|
15
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
16
|
+
|
|
17
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
18
|
+
|
|
11
19
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
20
|
|
|
13
21
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -37,7 +45,7 @@ var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/n
|
|
|
37
45
|
|
|
38
46
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
39
47
|
|
|
40
|
-
var
|
|
48
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
41
49
|
|
|
42
50
|
var _defaultsDeep2 = _interopRequireDefault(require("lodash/defaultsDeep"));
|
|
43
51
|
|
|
@@ -57,6 +65,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
|
|
|
57
65
|
|
|
58
66
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
59
67
|
|
|
68
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
69
|
+
|
|
70
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
71
|
+
|
|
60
72
|
var BASE_PATH_SECURE = '/users/test_users_s';
|
|
61
73
|
var BASE_PATH = '/users/test_users';
|
|
62
74
|
/**
|
|
@@ -181,20 +193,20 @@ function requestWithAuth(options) {
|
|
|
181
193
|
*/
|
|
182
194
|
|
|
183
195
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
* @typedef {Object} TestUserObject
|
|
197
|
+
* @property {string} password
|
|
198
|
+
* @property {string} emailAddress
|
|
199
|
+
* @property {string} displayName
|
|
200
|
+
* @property {string} id
|
|
201
|
+
* @property {string} userName
|
|
202
|
+
* @property {string} email
|
|
203
|
+
* @property {string} name
|
|
204
|
+
* @property {string} givenName
|
|
205
|
+
* @property {string} type
|
|
206
|
+
* @property {Array.<string>} entitlements
|
|
207
|
+
* @property {string} orgId
|
|
208
|
+
* @property {AccessTokenObject} token
|
|
209
|
+
*/
|
|
198
210
|
|
|
199
211
|
/**
|
|
200
212
|
* Creates a test user
|
|
@@ -248,11 +260,11 @@ function createTestUser() {
|
|
|
248
260
|
json: true,
|
|
249
261
|
body: body
|
|
250
262
|
}).then(function (res) {
|
|
251
|
-
return (
|
|
263
|
+
return _objectSpread(_objectSpread({
|
|
252
264
|
password: body.password,
|
|
253
265
|
emailAddress: res.body.user.email,
|
|
254
266
|
displayName: res.body.user.name
|
|
255
|
-
}, res.body.user, {
|
|
267
|
+
}, res.body.user), {}, {
|
|
256
268
|
token: fixToken(res.body.token)
|
|
257
269
|
});
|
|
258
270
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BASE_PATH_SECURE","BASE_PATH","fixToken","token","now","expires_in","expires","refresh_token_expires_in","refresh_token_expires","token_type","access_token","authorization","clientToken","getClientCredentials","clientId","clientSecret","idbrokerUrl","resolve","request","method","uri","json","form","grant_type","scope","client_id","client_secret","headers","btoa","then","res","body","requestWithAuth","options","createTestUser","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","IDBROKER_BASE_URL","cigServiceUrl","WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL","WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL","Error","authCodeOnly","displayName","randomName","emailTemplate","emailAddress","entitlements","machineType","orgId","password","uuid","v4","roles","scopes","WEBEX_SCOPE","type","user","email","name","loginTestUser","removeTestUser","id","reject","assert","user_id","refresh_token","user_type","userType"],"sources":["index.js"],"sourcesContent":["import assert from 'assert';\n\nimport uuid from 'uuid';\nimport btoa from 'btoa';\nimport _ from 'lodash';\nimport randomName from 'node-random-name';\nimport {request} from '@webex/http-core';\n\nconst BASE_PATH_SECURE = '/users/test_users_s';\nconst BASE_PATH = '/users/test_users';\n\n/**\n * Computes `expires` and `refresh_token_expires` from `expires_in` and\n * `refresh_token_expires_in` and creates an `authorization` string.\n * @param {Object} token\n * @private\n * @returns {Object}\n */\nfunction fixToken(token) {\n const now = Date.now();\n\n if (token.expires_in && !token.expires) {\n token.expires = now + token.expires_in * 1000;\n }\n\n if (token.refresh_token_expires_in && !token.refresh_token_expires) {\n /* eslint camelcase: [0] */\n token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;\n }\n\n if (token.token_type && token.access_token) {\n token.authorization = `${token.token_type} ${token.access_token}`;\n }\n\n return token;\n}\n\nlet clientToken;\n\n/**\n * Fetches credentials to talk to the test_users_s endpoint\n *\n * Caches result in `clientToken` variable for multiple runs\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @private\n * @returns {String}\n */\nfunction getClientCredentials({clientId, clientSecret, idbrokerUrl}) {\n if (clientToken) {\n return Promise.resolve(clientToken);\n }\n\n return request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n grant_type: 'client_credentials',\n scope: 'Identity:SCIM webexsquare:get_conversation',\n client_id: clientId,\n client_secret: clientSecret\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n authorization: btoa(`${clientId}:${clientSecret}`)\n }\n })\n .then((res) => {\n const token = fixToken(res.body);\n\n return `${token.token_type} ${token.access_token}`;\n })\n .then((token) => {\n clientToken = token;\n\n return clientToken;\n });\n}\n\n/**\n * Makes a request authorized with client credentials\n * @param {Object} options\n * @param {Object} options.body\n * @param {string} options.body.clientId\n * @param {string} options.body.clientSecret\n * @param {string} options.body.idbrokerUrl\n * @private\n * @returns {Promise<HttpResponseObject>}\n */\nfunction requestWithAuth(options) {\n return getClientCredentials(options.body)\n .then((authorization) => {\n options.headers = options.headers || {};\n options.headers.authorization = authorization;\n\n return request(options);\n });\n}\n\n/**\n * @typedef {Object} AccessTokenObject\n * @property {string} token.access_token\n * @property {Number} token.expires_in\n * @property {string} token.token_type\n * @property {string} token.refresh_token\n * @property {Number} token.refresh_token_expires_in\n * @property {string} token.expires\n * @property {string} token.refresh_token_expires\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @property {boolean} [authCodeOnly] generates auth_code\n * @param {string} [clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL\n * @property {string} [displayName]\n * @property {string} [emailAddress]\n * @property {Array.<string>} [entitlements]\n * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @property {string} [machineType] used when creating a machine user/device\n * @property {string} [orgId] organization ID to create the user under\n * @property {string} [password] defaults to a random password\n * @property {string} [roles] defaults to []\n * @property {string} [scope] defaults to WEBEX_SCOPE\n * @property {string} [type] used to create a machine\n */\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} id\n * @property {string} userName\n * @property {string} email\n * @property {string} name\n * @property {string} givenName\n * @property {string} type\n * @property {Array.<string>} entitlements\n * @property {string} orgId\n * @property {AccessTokenObject} token\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const cigServiceUrl = options.cigServiceUrl || process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL || process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error('options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined');\n }\n\n const body = {\n authCodeOnly: options.authCodeOnly,\n clientId,\n clientSecret,\n displayName: options.displayName || randomName(),\n emailTemplate: options.emailAddress,\n entitlements: options.entitlements || [\n 'spark',\n 'squaredCallInitiation',\n 'squaredRoomModeration',\n 'squaredInviter',\n 'webExSquared'\n ],\n idbrokerUrl,\n machineType: options.machineType,\n orgId: options.orgId,\n // The five characters on the end are to hit all the password requirements\n password: options.password || `${uuid.v4()}zAY1*`,\n roles: options.roles || [],\n scopes: options.scope || process.env.WEBEX_SCOPE,\n type: options.type\n };\n\n return requestWithAuth({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,\n json: true,\n body\n })\n .then((res) => Object.assign({\n password: body.password,\n emailAddress: res.body.user.email,\n displayName: res.body.user.name\n }, res.body.user, {token: fixToken(res.body.token)}));\n}\n\n/**\n * Exchanges a user name/password for an access token\n * @param {Object} options\n * @param {string} options.id\n * @param {string} options.email\n * @param {string} options.password\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.cigServiceUrl\n * @returns {Promise.<AccessTokenObject>}\n */\nexport function loginTestUser(options) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const cigServiceUrl = options.cigServiceUrl || process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL || process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error('options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined');\n }\n\n return request({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH}/login`,\n json: true,\n body: _.defaultsDeep(options, {\n clientId,\n clientSecret\n })\n })\n .then((res) => fixToken(res.body));\n}\n\n/**\n * Removes a test user\n * @param {Object} options\n * @param {string} options.id user id to remove\n * @param {string} options.cigServiceUrl\n * @param {Object} options.token\n * @param {string} options.token.authorization\n * @param {string} [options.token.refresh_token]\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n const cigServiceUrl = options.cigServiceUrl || process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL || process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!cigServiceUrl) {\n throw new Error('options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined');\n }\n\n if (!options.id) {\n return Promise.reject(new Error('options.id is required'));\n }\n\n if (!options.token) {\n return loginTestUser(options)\n .then((token) => {\n options.token = token;\n\n return removeTestUser(options);\n });\n }\n\n assert(options.token.authorization, 'options.token.authorization must be defined');\n\n return request({\n method: 'POST',\n json: true,\n headers: {\n authorization: options.token.authorization\n },\n body: {\n /* eslint-disable camelcase */\n user_id: options.id,\n refresh_token: options.token.refresh_token,\n user_type: options.userType || 'PERSON'\n /* eslint-enable camelcase */\n },\n uri: `${cigServiceUrl}${BASE_PATH}/delete`\n });\n}\n\nexport {\n default as createWhistlerTestUser,\n removeTestUser as removeWhistlerTestUser\n} from './whistler';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AACA;;AAuSA;;;;;;AArSA,IAAMA,gBAAgB,GAAG,qBAAzB;AACA,IAAMC,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAkB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;MACAoC,OAAO,EAAElC,OAAO,CAAC+B,EAFb;MAGJI,aAAa,EAAEnC,OAAO,CAAC9B,KAAR,CAAciE,aAHzB;MAIJC,SAAS,EAAEpC,OAAO,CAACqC,QAAR,IAAoB;MAC/B;;IALI,CANO;IAablD,GAAG,YAAKoB,aAAL,SAAqBvC,SAArB;EAbU,CAAR,CAAP;AAeD"}
|
|
1
|
+
{"version":3,"names":["BASE_PATH_SECURE","BASE_PATH","fixToken","token","now","expires_in","expires","refresh_token_expires_in","refresh_token_expires","token_type","access_token","authorization","clientToken","getClientCredentials","clientId","clientSecret","idbrokerUrl","resolve","request","method","uri","json","form","grant_type","scope","client_id","client_secret","headers","btoa","then","res","body","requestWithAuth","options","createTestUser","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","IDBROKER_BASE_URL","cigServiceUrl","WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL","WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL","Error","authCodeOnly","displayName","randomName","emailTemplate","emailAddress","entitlements","machineType","orgId","password","uuid","v4","roles","scopes","WEBEX_SCOPE","type","user","email","name","loginTestUser","removeTestUser","id","reject","assert","user_id","refresh_token","user_type","userType"],"sources":["index.js"],"sourcesContent":["import assert from 'assert';\n\nimport uuid from 'uuid';\nimport btoa from 'btoa';\nimport _ from 'lodash';\nimport randomName from 'node-random-name';\nimport {request} from '@webex/http-core';\n\nconst BASE_PATH_SECURE = '/users/test_users_s';\nconst BASE_PATH = '/users/test_users';\n\n/**\n * Computes `expires` and `refresh_token_expires` from `expires_in` and\n * `refresh_token_expires_in` and creates an `authorization` string.\n * @param {Object} token\n * @private\n * @returns {Object}\n */\nfunction fixToken(token) {\n const now = Date.now();\n\n if (token.expires_in && !token.expires) {\n token.expires = now + token.expires_in * 1000;\n }\n\n if (token.refresh_token_expires_in && !token.refresh_token_expires) {\n /* eslint camelcase: [0] */\n token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;\n }\n\n if (token.token_type && token.access_token) {\n token.authorization = `${token.token_type} ${token.access_token}`;\n }\n\n return token;\n}\n\nlet clientToken;\n\n/**\n * Fetches credentials to talk to the test_users_s endpoint\n *\n * Caches result in `clientToken` variable for multiple runs\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @private\n * @returns {String}\n */\nfunction getClientCredentials({clientId, clientSecret, idbrokerUrl}) {\n if (clientToken) {\n return Promise.resolve(clientToken);\n }\n\n return request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n grant_type: 'client_credentials',\n scope: 'Identity:SCIM webexsquare:get_conversation',\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n .then((res) => {\n const token = fixToken(res.body);\n\n return `${token.token_type} ${token.access_token}`;\n })\n .then((token) => {\n clientToken = token;\n\n return clientToken;\n });\n}\n\n/**\n * Makes a request authorized with client credentials\n * @param {Object} options\n * @param {Object} options.body\n * @param {string} options.body.clientId\n * @param {string} options.body.clientSecret\n * @param {string} options.body.idbrokerUrl\n * @private\n * @returns {Promise<HttpResponseObject>}\n */\nfunction requestWithAuth(options) {\n return getClientCredentials(options.body).then((authorization) => {\n options.headers = options.headers || {};\n options.headers.authorization = authorization;\n\n return request(options);\n });\n}\n\n/**\n * @typedef {Object} AccessTokenObject\n * @property {string} token.access_token\n * @property {Number} token.expires_in\n * @property {string} token.token_type\n * @property {string} token.refresh_token\n * @property {Number} token.refresh_token_expires_in\n * @property {string} token.expires\n * @property {string} token.refresh_token_expires\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @property {boolean} [authCodeOnly] generates auth_code\n * @param {string} [clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL\n * @property {string} [displayName]\n * @property {string} [emailAddress]\n * @property {Array.<string>} [entitlements]\n * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @property {string} [machineType] used when creating a machine user/device\n * @property {string} [orgId] organization ID to create the user under\n * @property {string} [password] defaults to a random password\n * @property {string} [roles] defaults to []\n * @property {string} [scope] defaults to WEBEX_SCOPE\n * @property {string} [type] used to create a machine\n */\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} id\n * @property {string} userName\n * @property {string} email\n * @property {string} name\n * @property {string} givenName\n * @property {string} type\n * @property {Array.<string>} entitlements\n * @property {string} orgId\n * @property {AccessTokenObject} token\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n const body = {\n authCodeOnly: options.authCodeOnly,\n clientId,\n clientSecret,\n displayName: options.displayName || randomName(),\n emailTemplate: options.emailAddress,\n entitlements: options.entitlements || [\n 'spark',\n 'squaredCallInitiation',\n 'squaredRoomModeration',\n 'squaredInviter',\n 'webExSquared',\n ],\n idbrokerUrl,\n machineType: options.machineType,\n orgId: options.orgId,\n // The five characters on the end are to hit all the password requirements\n password: options.password || `${uuid.v4()}zAY1*`,\n roles: options.roles || [],\n scopes: options.scope || process.env.WEBEX_SCOPE,\n type: options.type,\n };\n\n return requestWithAuth({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,\n json: true,\n body,\n }).then((res) => ({\n password: body.password,\n emailAddress: res.body.user.email,\n displayName: res.body.user.name,\n ...res.body.user,\n token: fixToken(res.body.token),\n }));\n}\n\n/**\n * Exchanges a user name/password for an access token\n * @param {Object} options\n * @param {string} options.id\n * @param {string} options.email\n * @param {string} options.password\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.cigServiceUrl\n * @returns {Promise.<AccessTokenObject>}\n */\nexport function loginTestUser(options) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n return request({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH}/login`,\n json: true,\n body: _.defaultsDeep(options, {\n clientId,\n clientSecret,\n }),\n }).then((res) => fixToken(res.body));\n}\n\n/**\n * Removes a test user\n * @param {Object} options\n * @param {string} options.id user id to remove\n * @param {string} options.cigServiceUrl\n * @param {Object} options.token\n * @param {string} options.token.authorization\n * @param {string} [options.token.refresh_token]\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n if (!options.id) {\n return Promise.reject(new Error('options.id is required'));\n }\n\n if (!options.token) {\n return loginTestUser(options).then((token) => {\n options.token = token;\n\n return removeTestUser(options);\n });\n }\n\n assert(options.token.authorization, 'options.token.authorization must be defined');\n\n return request({\n method: 'POST',\n json: true,\n headers: {\n authorization: options.token.authorization,\n },\n body: {\n /* eslint-disable camelcase */\n user_id: options.id,\n refresh_token: options.token.refresh_token,\n user_type: options.userType || 'PERSON',\n /* eslint-enable camelcase */\n },\n uri: `${cigServiceUrl}${BASE_PATH}/delete`,\n });\n}\n\nexport {\n default as createWhistlerTestUser,\n removeTestUser as removeWhistlerTestUser,\n} from './whistler';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AACA;;AAoTA;;;;;;;;;;AAlTA,IAAMA,gBAAgB,GAAG,qBAAzB;AACA,IAAMC,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAkBC,KAAlB,EAAyB;EACvB,IAAMC,GAAG,GAAG,mBAAZ;;EAEA,IAAID,KAAK,CAACE,UAAN,IAAoB,CAACF,KAAK,CAACG,OAA/B,EAAwC;IACtCH,KAAK,CAACG,OAAN,GAAgBF,GAAG,GAAGD,KAAK,CAACE,UAAN,GAAmB,IAAzC;EACD;;EAED,IAAIF,KAAK,CA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5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
+
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
+
|
|
7
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
8
|
+
|
|
9
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
10
|
+
|
|
11
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
12
|
+
|
|
3
13
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
14
|
|
|
5
15
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
@@ -11,12 +21,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
11
21
|
exports.default = createTestUser;
|
|
12
22
|
exports.removeTestUser = removeTestUser;
|
|
13
23
|
|
|
14
|
-
var
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
15
25
|
|
|
16
26
|
var _btoa = _interopRequireDefault(require("btoa"));
|
|
17
27
|
|
|
18
28
|
var _httpCore = require("@webex/http-core");
|
|
19
29
|
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
20
34
|
/**
|
|
21
35
|
* Fetches credentials/access_token to talk to the whistler endpoint
|
|
22
36
|
*
|
|
@@ -71,14 +85,14 @@ var getClientCredentials = function getClientCredentials(_ref) {
|
|
|
71
85
|
});
|
|
72
86
|
};
|
|
73
87
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
* @typedef {Object} TestUserObject
|
|
89
|
+
* @property {string} password
|
|
90
|
+
* @property {string} emailAddress
|
|
91
|
+
* @property {string} displayName
|
|
92
|
+
* @property {string} token
|
|
93
|
+
* @property {string} reservationUrl
|
|
94
|
+
* @property {object} responseMetaData - whistler given properties
|
|
95
|
+
*/
|
|
82
96
|
|
|
83
97
|
/**
|
|
84
98
|
* @typedef {Object} CreateUserOptions
|
|
@@ -162,7 +176,7 @@ function createTestUser() {
|
|
|
162
176
|
}
|
|
163
177
|
});
|
|
164
178
|
}).then(function (res) {
|
|
165
|
-
return (
|
|
179
|
+
return _objectSpread({
|
|
166
180
|
password: res.body.responseMetaData.ciPassword,
|
|
167
181
|
emailAddress: res.body.responseMetaData.name,
|
|
168
182
|
displayName: res.body.responseMetaData.webExUserName,
|
package/dist/whistler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getClientCredentials","clientId","clientSecret","orgId","idbrokerUrl","machineAccount","machinePassword","request","method","uri","json","body","uid","password","then","res","form","assertion","BearerToken","grant_type","scope","self_contained_token","client_id","client_secret","headers","authorization","btoa","token_type","access_token","createTestUser","options","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","WHISTLER_MACHINE_ACCOUNT","WHISTLER_MACHINE_PASSWORD","IDBROKER_BASE_URL","WHISTLER_TEST_ORG_ID","whistlerServiceUrl","WHISTLER_API_SERVICE_URL","reservationGroup","userScopes","Error","qs","isAccessTokenRequired","responseMetaData","ciPassword","emailAddress","name","displayName","webExUserName","token","ciAccessToken","reservationUrl","removeTestUser"],"sources":["whistler.js"],"sourcesContent":["import btoa from 'btoa';\nimport {request} from '@webex/http-core';\n\n/**\n * Fetches credentials/access_token to talk to the whistler endpoint\n *\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @param {string} options.orgId\n * @param {string} options.machineAccount\n * @param {string} options.machinePassword\n * @private\n * @returns {Promise<string>}\n */\nconst getClientCredentials = ({\n clientId,\n clientSecret,\n orgId,\n idbrokerUrl,\n machineAccount,\n machinePassword\n}) => request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,\n json: true,\n body: {\n uid: machineAccount,\n password: machinePassword\n }\n})\n .then((res) => request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n assertion: res.body.BearerToken,\n grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',\n scope: 'webexsquare:get_conversation webexsquare:admin',\n self_contained_token: true,\n client_id: clientId,\n client_secret: clientSecret\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n // authorization: `Basic + ${btoa(`${clientId}:${clientSecret}`)}`\n authorization: btoa(`${clientId}:${clientSecret}`)\n }\n }))\n .then((res) => `${res.body.token_type} ${res.body.access_token}`);\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} token\n * @property {string} reservationUrl\n * @property {object} responseMetaData - whistler given properties\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @param {Object} [options]\n * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL\n * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @param {string} [options.orgId] organization ID to create the user under\n * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT\n * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport default function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT;\n const machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;\n const whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;\n const {reservationGroup, userScopes} = options;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!machineAccount) {\n throw new Error('options.machineAccount or process.env.WHISTLER_MACHINE_ACCOUNT must be defined');\n }\n\n if (!machinePassword) {\n throw new Error('options.machinePassword or process.env.WHISTLER_MACHINE_PASSWORD must be defined');\n }\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!orgId) {\n throw new Error('options.orgId or process.env.WHISTLER_TEST_ORG_ID must be defined');\n }\n\n if (!whistlerServiceUrl) {\n throw new Error('options.whistlerServiceUrl or process.env.WHISTLER_API_SERVICE_URL must be defined');\n }\n\n // For reservation groups and user scopes\n // Please check https://confluence-eng-gpk2.cisco.com/conf/pages/viewpage.action?spaceKey=LOCUS&title=Whistler+APIs#WhistlerAPIs-GET/reservations/testUser\n return getClientCredentials({\n clientId,\n clientSecret,\n machineAccount,\n machinePassword,\n idbrokerUrl,\n orgId\n })\n .then((authorization) => request({\n method: 'GET',\n uri: `${whistlerServiceUrl}/reservations/testUser`,\n qs: {\n reservationGroup,\n userScopes,\n isAccessTokenRequired: true\n },\n headers: {\n authorization\n }\n }))\n .then((res) => Object.assign({\n password: res.body.responseMetaData.ciPassword,\n emailAddress: res.body.responseMetaData.name,\n displayName: res.body.responseMetaData.webExUserName,\n token: res.body.responseMetaData.ciAccessToken,\n reservationUrl: res.body.reservationUrl\n }, res.body.responseMetaData));\n}\n\n/**\n *\n * @param {Object} options\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n return request({\n method: 'DELETE',\n headers: {\n authorization: `Bearer ${options.token}`\n },\n uri: options.reservationUrl\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB;EAAA,IAC3BC,QAD2B,QAC3BA,QAD2B;EAAA,IAE3BC,YAF2B,QAE3BA,YAF2B;EAAA,IAG3BC,KAH2B,QAG3BA,KAH2B;EAAA,IAI3BC,WAJ2B,QAI3BA,WAJ2B;EAAA,IAK3BC,cAL2B,QAK3BA,cAL2B;EAAA,IAM3BC,eAN2B,QAM3BA,eAN2B;EAAA,OAOvB,IAAAC,iBAAA,EAAQ;IACZC,MAAM,EAAE,MADI;IAEZC,GAAG,YAAKL,WAAL,wBAA8BD,KAA9B,sCAFS;IAGZO,IAAI,EAAE,IAHM;IAIZC,IAAI,EAAE;MACJC,GAAG,EAAEP,cADD;MAEJQ,QAAQ,EAAEP;IAFN;EAJM,CAAR,EASHQ,IATG,CASE,UAACC,GAAD;IAAA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MAE/BC,GAAG,YAAK8B,kBAAL,2BAF4B;MAG/BK,EAAE,EAAE;QACFH,gBAAgB,EAAhBA,gBADE;QAEFC,UAAU,EAAVA,UAFE;QAGFG,qBAAqB,EAAE;MAHrB,CAH2B;MAQ/BrB,OAAO,EAAE;QACPC,aAAa,EAAbA;MADO;IARsB,CAAR,CAAnB;EAAA,CARD,EAoBJX,IApBI,CAoBC,UAACC,GAAD;IAAA,OAAS,qBAAc;MAC3BF,QAAQ,EAAEE,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BC,UADT;MAE3BC,YAAY,EAAEjC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BG,IAFb;MAG3BC,WAAW,EAAEnC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BK,aAHZ;MAI3BC,KAAK,EAAErC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BO,aAJN;MAK3BC,cAAc,EAAEvC,GAAG,CAACJ,IAAJ,CAAS2C;IALE,CAAd,EAMZvC,GAAG,CAACJ,IAAJ,CAASmC,gBANG,CAAT;EAAA,CApBD,CAAP;AA2BD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASS,cAAT,GAAsC;EAAA,IAAdzB,OAAc,uEAAJ,EAAI;EAC3C,OAAO,IAAAvB,iBAAA,EAAQ;IACbC,MAAM,EAAE,QADK;IAEbgB,OAAO,EAAE;MACPC,aAAa,mBAAYK,OAAO,CAACsB,KAApB;IADN,CAFI;IAKb3C,GAAG,EAAEqB,OAAO,CAACwB;EALA,CAAR,CAAP;AAOD"}
|
|
1
|
+
{"version":3,"names":["getClientCredentials","clientId","clientSecret","orgId","idbrokerUrl","machineAccount","machinePassword","request","method","uri","json","body","uid","password","then","res","form","assertion","BearerToken","grant_type","scope","self_contained_token","client_id","client_secret","headers","authorization","btoa","token_type","access_token","createTestUser","options","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","WHISTLER_MACHINE_ACCOUNT","WHISTLER_MACHINE_PASSWORD","IDBROKER_BASE_URL","WHISTLER_TEST_ORG_ID","whistlerServiceUrl","WHISTLER_API_SERVICE_URL","reservationGroup","userScopes","Error","qs","isAccessTokenRequired","responseMetaData","ciPassword","emailAddress","name","displayName","webExUserName","token","ciAccessToken","reservationUrl","removeTestUser"],"sources":["whistler.js"],"sourcesContent":["import btoa from 'btoa';\nimport {request} from '@webex/http-core';\n\n/**\n * Fetches credentials/access_token to talk to the whistler endpoint\n *\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @param {string} options.orgId\n * @param {string} options.machineAccount\n * @param {string} options.machinePassword\n * @private\n * @returns {Promise<string>}\n */\nconst getClientCredentials = ({\n clientId,\n clientSecret,\n orgId,\n idbrokerUrl,\n machineAccount,\n machinePassword,\n}) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,\n json: true,\n body: {\n uid: machineAccount,\n password: machinePassword,\n },\n })\n .then((res) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n assertion: res.body.BearerToken,\n grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',\n scope: 'webexsquare:get_conversation webexsquare:admin',\n self_contained_token: true,\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n // authorization: `Basic + ${btoa(`${clientId}:${clientSecret}`)}`\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n )\n .then((res) => `${res.body.token_type} ${res.body.access_token}`);\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} token\n * @property {string} reservationUrl\n * @property {object} responseMetaData - whistler given properties\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @param {Object} [options]\n * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL\n * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @param {string} [options.orgId] organization ID to create the user under\n * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT\n * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport default function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT;\n const machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;\n const whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;\n const {reservationGroup, userScopes} = options;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!machineAccount) {\n throw new Error(\n 'options.machineAccount or process.env.WHISTLER_MACHINE_ACCOUNT must be defined'\n );\n }\n\n if (!machinePassword) {\n throw new Error(\n 'options.machinePassword or process.env.WHISTLER_MACHINE_PASSWORD must be defined'\n );\n }\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!orgId) {\n throw new Error('options.orgId or process.env.WHISTLER_TEST_ORG_ID must be defined');\n }\n\n if (!whistlerServiceUrl) {\n throw new Error(\n 'options.whistlerServiceUrl or process.env.WHISTLER_API_SERVICE_URL must be defined'\n );\n }\n\n // For reservation groups and user scopes\n // Please check https://confluence-eng-gpk2.cisco.com/conf/pages/viewpage.action?spaceKey=LOCUS&title=Whistler+APIs#WhistlerAPIs-GET/reservations/testUser\n return getClientCredentials({\n clientId,\n clientSecret,\n machineAccount,\n machinePassword,\n idbrokerUrl,\n orgId,\n })\n .then((authorization) =>\n request({\n method: 'GET',\n uri: `${whistlerServiceUrl}/reservations/testUser`,\n qs: {\n reservationGroup,\n userScopes,\n isAccessTokenRequired: true,\n },\n headers: {\n authorization,\n },\n })\n )\n .then((res) => ({\n password: res.body.responseMetaData.ciPassword,\n emailAddress: res.body.responseMetaData.name,\n displayName: res.body.responseMetaData.webExUserName,\n token: res.body.responseMetaData.ciAccessToken,\n reservationUrl: res.body.reservationUrl,\n ...res.body.responseMetaData,\n }));\n}\n\n/**\n *\n * @param {Object} options\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n return request({\n method: 'DELETE',\n headers: {\n authorization: `Bearer ${options.token}`,\n },\n uri: options.reservationUrl,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB;EAAA,IAC3BC,QAD2B,QAC3BA,QAD2B;EAAA,IAE3BC,YAF2B,QAE3BA,YAF2B;EAAA,IAG3BC,KAH2B,QAG3BA,KAH2B;EAAA,IAI3BC,WAJ2B,QAI3BA,WAJ2B;EAAA,IAK3BC,cAL2B,QAK3BA,cAL2B;EAAA,IAM3BC,eAN2B,QAM3BA,eAN2B;EAAA,OAQ3B,IAAAC,iBAAA,EAAQ;IACNC,MAAM,EAAE,MADF;IAENC,GAAG,YAAKL,WAAL,wBAA8BD,KAA9B,sCAFG;IAGNO,IAAI,EAAE,IAHA;IAINC,IAAI,EAAE;MACJC,GAAG,EAAEP,cADD;M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AD;IAAA,OACJ,IAAAlB,iBAAA,EAAQ;MACNC,MAAM,EAAE,KADF;MAENC,GAAG,YAAK8B,kBAAL,2BAFG;MAGNK,EAAE,EAAE;QACFH,gBAAgB,EAAhBA,gBADE;QAEFC,UAAU,EAAVA,UAFE;QAGFG,qBAAqB,EAAE;MAHrB,CAHE;MAQNrB,OAAO,EAAE;QACPC,aAAa,EAAbA;MADO;IARH,CAAR,CADI;EAAA,CARD,EAsBJX,IAtBI,CAsBC,UAACC,GAAD;IAAA;MACJF,QAAQ,EAAEE,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BC,UADhC;MAEJC,YAAY,EAAEjC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BG,IAFpC;MAGJC,WAAW,EAAEnC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BK,aAHnC;MAIJC,KAAK,EAAErC,GAAG,CAACJ,IAAJ,CAASmC,gBAAT,CAA0BO,aAJ7B;MAKJC,cAAc,EAAEvC,GAAG,CAACJ,IAAJ,CAAS2C;IALrB,GAMDvC,GAAG,CAACJ,IAAJ,CAASmC,gBANR;EAAA,CAtBD,CAAP;AA8BD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASS,cAAT,GAAsC;EAAA,IAAdzB,OAAc,uEAAJ,EAAI;EAC3C,OAAO,IAAAvB,iBAAA,EAAQ;IACbC,MAAM,EAAE,QADK;IAEbgB,OAAO,EAAE;MACPC,aAAa,mBAAYK,OAAO,CAACsB,KAApB;IADN,CAFI;IAKb3C,GAAG,EAAEqB,OAAO,CAACwB;EALA,CAAR,CAAP;AAOD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/test-users",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.15",
|
|
4
4
|
"description": "Cisco Webex Test Users",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"chai-as-promised": "^7.1.1"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@webex/http-core": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
29
|
-
"@webex/test-users": "3.0.0-beta.
|
|
27
|
+
"@webex/http-core": "3.0.0-beta.15",
|
|
28
|
+
"@webex/test-helper-mocha": "3.0.0-beta.15",
|
|
29
|
+
"@webex/test-users": "3.0.0-beta.15",
|
|
30
30
|
"btoa": "^1.2.1",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
32
|
"node-random-name": "^1.0.1",
|
package/src/index.js
CHANGED
|
@@ -24,7 +24,7 @@ function fixToken(token) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (token.refresh_token_expires_in && !token.refresh_token_expires) {
|
|
27
|
-
|
|
27
|
+
/* eslint camelcase: [0] */
|
|
28
28
|
token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -61,14 +61,14 @@ function getClientCredentials({clientId, clientSecret, idbrokerUrl}) {
|
|
|
61
61
|
grant_type: 'client_credentials',
|
|
62
62
|
scope: 'Identity:SCIM webexsquare:get_conversation',
|
|
63
63
|
client_id: clientId,
|
|
64
|
-
client_secret: clientSecret
|
|
64
|
+
client_secret: clientSecret,
|
|
65
65
|
},
|
|
66
66
|
headers: {
|
|
67
67
|
// Note: we can't request's auth hash here because this endpoint expects
|
|
68
68
|
// us to send the auth header *without including "Basic "* before the
|
|
69
69
|
// token string
|
|
70
|
-
authorization: btoa(`${clientId}:${clientSecret}`)
|
|
71
|
-
}
|
|
70
|
+
authorization: btoa(`${clientId}:${clientSecret}`),
|
|
71
|
+
},
|
|
72
72
|
})
|
|
73
73
|
.then((res) => {
|
|
74
74
|
const token = fixToken(res.body);
|
|
@@ -93,13 +93,12 @@ function getClientCredentials({clientId, clientSecret, idbrokerUrl}) {
|
|
|
93
93
|
* @returns {Promise<HttpResponseObject>}
|
|
94
94
|
*/
|
|
95
95
|
function requestWithAuth(options) {
|
|
96
|
-
return getClientCredentials(options.body)
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
options.headers.authorization = authorization;
|
|
96
|
+
return getClientCredentials(options.body).then((authorization) => {
|
|
97
|
+
options.headers = options.headers || {};
|
|
98
|
+
options.headers.authorization = authorization;
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
return request(options);
|
|
101
|
+
});
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
/**
|
|
@@ -132,20 +131,20 @@ function requestWithAuth(options) {
|
|
|
132
131
|
*/
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
* @typedef {Object} TestUserObject
|
|
135
|
+
* @property {string} password
|
|
136
|
+
* @property {string} emailAddress
|
|
137
|
+
* @property {string} displayName
|
|
138
|
+
* @property {string} id
|
|
139
|
+
* @property {string} userName
|
|
140
|
+
* @property {string} email
|
|
141
|
+
* @property {string} name
|
|
142
|
+
* @property {string} givenName
|
|
143
|
+
* @property {string} type
|
|
144
|
+
* @property {Array.<string>} entitlements
|
|
145
|
+
* @property {string} orgId
|
|
146
|
+
* @property {AccessTokenObject} token
|
|
147
|
+
*/
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
150
|
* Creates a test user
|
|
@@ -156,7 +155,10 @@ export function createTestUser(options = {}) {
|
|
|
156
155
|
const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
157
156
|
const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
158
157
|
const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;
|
|
159
|
-
const cigServiceUrl =
|
|
158
|
+
const cigServiceUrl =
|
|
159
|
+
options.cigServiceUrl ||
|
|
160
|
+
process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||
|
|
161
|
+
process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;
|
|
160
162
|
|
|
161
163
|
if (!clientId) {
|
|
162
164
|
throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');
|
|
@@ -171,7 +173,9 @@ export function createTestUser(options = {}) {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
if (!cigServiceUrl) {
|
|
174
|
-
throw new Error(
|
|
176
|
+
throw new Error(
|
|
177
|
+
'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'
|
|
178
|
+
);
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
const body = {
|
|
@@ -185,7 +189,7 @@ export function createTestUser(options = {}) {
|
|
|
185
189
|
'squaredCallInitiation',
|
|
186
190
|
'squaredRoomModeration',
|
|
187
191
|
'squaredInviter',
|
|
188
|
-
'webExSquared'
|
|
192
|
+
'webExSquared',
|
|
189
193
|
],
|
|
190
194
|
idbrokerUrl,
|
|
191
195
|
machineType: options.machineType,
|
|
@@ -194,20 +198,21 @@ export function createTestUser(options = {}) {
|
|
|
194
198
|
password: options.password || `${uuid.v4()}zAY1*`,
|
|
195
199
|
roles: options.roles || [],
|
|
196
200
|
scopes: options.scope || process.env.WEBEX_SCOPE,
|
|
197
|
-
type: options.type
|
|
201
|
+
type: options.type,
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
return requestWithAuth({
|
|
201
205
|
method: 'POST',
|
|
202
206
|
uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,
|
|
203
207
|
json: true,
|
|
204
|
-
body
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
body,
|
|
209
|
+
}).then((res) => ({
|
|
210
|
+
password: body.password,
|
|
211
|
+
emailAddress: res.body.user.email,
|
|
212
|
+
displayName: res.body.user.name,
|
|
213
|
+
...res.body.user,
|
|
214
|
+
token: fixToken(res.body.token),
|
|
215
|
+
}));
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
/**
|
|
@@ -224,7 +229,10 @@ export function createTestUser(options = {}) {
|
|
|
224
229
|
export function loginTestUser(options) {
|
|
225
230
|
const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
226
231
|
const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
227
|
-
const cigServiceUrl =
|
|
232
|
+
const cigServiceUrl =
|
|
233
|
+
options.cigServiceUrl ||
|
|
234
|
+
process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||
|
|
235
|
+
process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;
|
|
228
236
|
|
|
229
237
|
if (!clientId) {
|
|
230
238
|
throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');
|
|
@@ -235,7 +243,9 @@ export function loginTestUser(options) {
|
|
|
235
243
|
}
|
|
236
244
|
|
|
237
245
|
if (!cigServiceUrl) {
|
|
238
|
-
throw new Error(
|
|
246
|
+
throw new Error(
|
|
247
|
+
'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'
|
|
248
|
+
);
|
|
239
249
|
}
|
|
240
250
|
|
|
241
251
|
return request({
|
|
@@ -244,10 +254,9 @@ export function loginTestUser(options) {
|
|
|
244
254
|
json: true,
|
|
245
255
|
body: _.defaultsDeep(options, {
|
|
246
256
|
clientId,
|
|
247
|
-
clientSecret
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
.then((res) => fixToken(res.body));
|
|
257
|
+
clientSecret,
|
|
258
|
+
}),
|
|
259
|
+
}).then((res) => fixToken(res.body));
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
/**
|
|
@@ -261,10 +270,15 @@ export function loginTestUser(options) {
|
|
|
261
270
|
* @returns {Promise}
|
|
262
271
|
*/
|
|
263
272
|
export function removeTestUser(options = {}) {
|
|
264
|
-
const cigServiceUrl =
|
|
273
|
+
const cigServiceUrl =
|
|
274
|
+
options.cigServiceUrl ||
|
|
275
|
+
process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||
|
|
276
|
+
process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;
|
|
265
277
|
|
|
266
278
|
if (!cigServiceUrl) {
|
|
267
|
-
throw new Error(
|
|
279
|
+
throw new Error(
|
|
280
|
+
'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'
|
|
281
|
+
);
|
|
268
282
|
}
|
|
269
283
|
|
|
270
284
|
if (!options.id) {
|
|
@@ -272,12 +286,11 @@ export function removeTestUser(options = {}) {
|
|
|
272
286
|
}
|
|
273
287
|
|
|
274
288
|
if (!options.token) {
|
|
275
|
-
return loginTestUser(options)
|
|
276
|
-
.
|
|
277
|
-
options.token = token;
|
|
289
|
+
return loginTestUser(options).then((token) => {
|
|
290
|
+
options.token = token;
|
|
278
291
|
|
|
279
|
-
|
|
280
|
-
|
|
292
|
+
return removeTestUser(options);
|
|
293
|
+
});
|
|
281
294
|
}
|
|
282
295
|
|
|
283
296
|
assert(options.token.authorization, 'options.token.authorization must be defined');
|
|
@@ -286,20 +299,20 @@ export function removeTestUser(options = {}) {
|
|
|
286
299
|
method: 'POST',
|
|
287
300
|
json: true,
|
|
288
301
|
headers: {
|
|
289
|
-
authorization: options.token.authorization
|
|
302
|
+
authorization: options.token.authorization,
|
|
290
303
|
},
|
|
291
304
|
body: {
|
|
292
305
|
/* eslint-disable camelcase */
|
|
293
306
|
user_id: options.id,
|
|
294
307
|
refresh_token: options.token.refresh_token,
|
|
295
|
-
user_type: options.userType || 'PERSON'
|
|
308
|
+
user_type: options.userType || 'PERSON',
|
|
296
309
|
/* eslint-enable camelcase */
|
|
297
310
|
},
|
|
298
|
-
uri: `${cigServiceUrl}${BASE_PATH}/delete
|
|
311
|
+
uri: `${cigServiceUrl}${BASE_PATH}/delete`,
|
|
299
312
|
});
|
|
300
313
|
}
|
|
301
314
|
|
|
302
315
|
export {
|
|
303
316
|
default as createWhistlerTestUser,
|
|
304
|
-
removeTestUser as removeWhistlerTestUser
|
|
317
|
+
removeTestUser as removeWhistlerTestUser,
|
|
305
318
|
} from './whistler';
|
package/src/whistler.js
CHANGED
|
@@ -20,47 +20,50 @@ const getClientCredentials = ({
|
|
|
20
20
|
orgId,
|
|
21
21
|
idbrokerUrl,
|
|
22
22
|
machineAccount,
|
|
23
|
-
machinePassword
|
|
24
|
-
}) =>
|
|
25
|
-
|
|
26
|
-
uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,
|
|
27
|
-
json: true,
|
|
28
|
-
body: {
|
|
29
|
-
uid: machineAccount,
|
|
30
|
-
password: machinePassword
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.then((res) => request({
|
|
23
|
+
machinePassword,
|
|
24
|
+
}) =>
|
|
25
|
+
request({
|
|
34
26
|
method: 'POST',
|
|
35
|
-
uri: `${idbrokerUrl}/idb/
|
|
27
|
+
uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,
|
|
36
28
|
json: true,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
scope: 'webexsquare:get_conversation webexsquare:admin',
|
|
41
|
-
self_contained_token: true,
|
|
42
|
-
client_id: clientId,
|
|
43
|
-
client_secret: clientSecret
|
|
29
|
+
body: {
|
|
30
|
+
uid: machineAccount,
|
|
31
|
+
password: machinePassword,
|
|
44
32
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
})
|
|
34
|
+
.then((res) =>
|
|
35
|
+
request({
|
|
36
|
+
method: 'POST',
|
|
37
|
+
uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,
|
|
38
|
+
json: true,
|
|
39
|
+
form: {
|
|
40
|
+
assertion: res.body.BearerToken,
|
|
41
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',
|
|
42
|
+
scope: 'webexsquare:get_conversation webexsquare:admin',
|
|
43
|
+
self_contained_token: true,
|
|
44
|
+
client_id: clientId,
|
|
45
|
+
client_secret: clientSecret,
|
|
46
|
+
},
|
|
47
|
+
headers: {
|
|
48
|
+
// Note: we can't request's auth hash here because this endpoint expects
|
|
49
|
+
// us to send the auth header *without including "Basic "* before the
|
|
50
|
+
// token string
|
|
51
|
+
// authorization: `Basic + ${btoa(`${clientId}:${clientSecret}`)}`
|
|
52
|
+
authorization: btoa(`${clientId}:${clientSecret}`),
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
.then((res) => `${res.body.token_type} ${res.body.access_token}`);
|
|
54
57
|
|
|
55
58
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
* @typedef {Object} TestUserObject
|
|
60
|
+
* @property {string} password
|
|
61
|
+
* @property {string} emailAddress
|
|
62
|
+
* @property {string} displayName
|
|
63
|
+
* @property {string} token
|
|
64
|
+
* @property {string} reservationUrl
|
|
65
|
+
* @property {object} responseMetaData - whistler given properties
|
|
66
|
+
*/
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
69
|
* @typedef {Object} CreateUserOptions
|
|
@@ -98,11 +101,15 @@ export default function createTestUser(options = {}) {
|
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
if (!machineAccount) {
|
|
101
|
-
throw new Error(
|
|
104
|
+
throw new Error(
|
|
105
|
+
'options.machineAccount or process.env.WHISTLER_MACHINE_ACCOUNT must be defined'
|
|
106
|
+
);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
if (!machinePassword) {
|
|
105
|
-
throw new Error(
|
|
110
|
+
throw new Error(
|
|
111
|
+
'options.machinePassword or process.env.WHISTLER_MACHINE_PASSWORD must be defined'
|
|
112
|
+
);
|
|
106
113
|
}
|
|
107
114
|
if (!idbrokerUrl) {
|
|
108
115
|
throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');
|
|
@@ -113,7 +120,9 @@ export default function createTestUser(options = {}) {
|
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
if (!whistlerServiceUrl) {
|
|
116
|
-
throw new Error(
|
|
123
|
+
throw new Error(
|
|
124
|
+
'options.whistlerServiceUrl or process.env.WHISTLER_API_SERVICE_URL must be defined'
|
|
125
|
+
);
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
// For reservation groups and user scopes
|
|
@@ -124,27 +133,30 @@ export default function createTestUser(options = {}) {
|
|
|
124
133
|
machineAccount,
|
|
125
134
|
machinePassword,
|
|
126
135
|
idbrokerUrl,
|
|
127
|
-
orgId
|
|
136
|
+
orgId,
|
|
128
137
|
})
|
|
129
|
-
.then((authorization) =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
.then((authorization) =>
|
|
139
|
+
request({
|
|
140
|
+
method: 'GET',
|
|
141
|
+
uri: `${whistlerServiceUrl}/reservations/testUser`,
|
|
142
|
+
qs: {
|
|
143
|
+
reservationGroup,
|
|
144
|
+
userScopes,
|
|
145
|
+
isAccessTokenRequired: true,
|
|
146
|
+
},
|
|
147
|
+
headers: {
|
|
148
|
+
authorization,
|
|
149
|
+
},
|
|
150
|
+
})
|
|
151
|
+
)
|
|
152
|
+
.then((res) => ({
|
|
142
153
|
password: res.body.responseMetaData.ciPassword,
|
|
143
154
|
emailAddress: res.body.responseMetaData.name,
|
|
144
155
|
displayName: res.body.responseMetaData.webExUserName,
|
|
145
156
|
token: res.body.responseMetaData.ciAccessToken,
|
|
146
|
-
reservationUrl: res.body.reservationUrl
|
|
147
|
-
|
|
157
|
+
reservationUrl: res.body.reservationUrl,
|
|
158
|
+
...res.body.responseMetaData,
|
|
159
|
+
}));
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
/**
|
|
@@ -156,8 +168,8 @@ export function removeTestUser(options = {}) {
|
|
|
156
168
|
return request({
|
|
157
169
|
method: 'DELETE',
|
|
158
170
|
headers: {
|
|
159
|
-
authorization: `Bearer ${options.token}
|
|
171
|
+
authorization: `Bearer ${options.token}`,
|
|
160
172
|
},
|
|
161
|
-
uri: options.reservationUrl
|
|
173
|
+
uri: options.reservationUrl,
|
|
162
174
|
});
|
|
163
175
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import chai from 'chai';
|
|
3
2
|
import chaiAsPromised from 'chai-as-promised';
|
|
4
3
|
import uuid from 'uuid';
|
|
@@ -15,7 +14,10 @@ assert.hasAccessToken = (user) => {
|
|
|
15
14
|
assert.isDefined(user.token.expires_in, 'user.token.expires_in is defined');
|
|
16
15
|
assert.isDefined(user.token.token_type, 'user.token.token_type is defined');
|
|
17
16
|
assert.isDefined(user.token.refresh_token, 'user.token.refresh_token is defined');
|
|
18
|
-
assert.isDefined(
|
|
17
|
+
assert.isDefined(
|
|
18
|
+
user.token.refresh_token_expires_in,
|
|
19
|
+
'user.token.refresh_token_expires_in is defined'
|
|
20
|
+
);
|
|
19
21
|
assert.isDefined(user.token.expires, 'user.token.expires is defined');
|
|
20
22
|
assert.isDefined(user.token.refresh_token_expires, 'user.token.refresh_token_expires is defined');
|
|
21
23
|
};
|
|
@@ -28,7 +30,10 @@ assert.hasAuthorizationCode = (user) => {
|
|
|
28
30
|
assert.hasRefreshToken = (user) => {
|
|
29
31
|
assert.isDefined(user.token, 'user.token is defined');
|
|
30
32
|
assert.isDefined(user.token.refresh_token, 'user.token.refresh_token is defined');
|
|
31
|
-
assert.isDefined(
|
|
33
|
+
assert.isDefined(
|
|
34
|
+
user.token.refresh_token_expires_in,
|
|
35
|
+
'user.token.refresh_token_expires_in is defined'
|
|
36
|
+
);
|
|
32
37
|
assert.isDefined(user.token.refresh_token_expires, 'user.token.refresh_token_expires is defined');
|
|
33
38
|
};
|
|
34
39
|
|
|
@@ -50,7 +55,7 @@ nodeOnly(describe)('test-users', () => {
|
|
|
50
55
|
return {
|
|
51
56
|
id: user.id,
|
|
52
57
|
email: user.emailAddress || user.email,
|
|
53
|
-
password: user.password
|
|
58
|
+
password: user.password,
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -59,51 +64,53 @@ nodeOnly(describe)('test-users', () => {
|
|
|
59
64
|
|
|
60
65
|
return request({
|
|
61
66
|
method: 'POST',
|
|
62
|
-
uri: `${
|
|
67
|
+
uri: `${
|
|
68
|
+
process.env.IDBROKER_BASE_URL || 'https://idbroker.webex.com'
|
|
69
|
+
}/idb/oauth2/v1/access_token`,
|
|
63
70
|
form: {
|
|
64
71
|
/* eslint-disable camelcase */
|
|
65
72
|
grant_type: 'refresh_token',
|
|
66
73
|
redirect_uri: process.env.WEBEX_REDIRECT_URI,
|
|
67
|
-
refresh_token: user.token.refresh_token
|
|
74
|
+
refresh_token: user.token.refresh_token,
|
|
68
75
|
/* eslint-enable */
|
|
69
76
|
},
|
|
70
77
|
auth: {
|
|
71
78
|
user: process.env.WEBEX_CLIENT_ID,
|
|
72
|
-
pass: process.env.WEBEX_CLIENT_SECRET
|
|
73
|
-
}
|
|
79
|
+
pass: process.env.WEBEX_CLIENT_SECRET,
|
|
80
|
+
},
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
describe('createTestUser()', () => {
|
|
78
|
-
it('creates a test user', () =>
|
|
79
|
-
.then((u) => {
|
|
85
|
+
it('creates a test user', () =>
|
|
86
|
+
createTestUser().then((u) => {
|
|
80
87
|
assert.isTestUser(u);
|
|
81
88
|
assert.hasAccessToken(u);
|
|
82
89
|
}));
|
|
83
90
|
|
|
84
|
-
it('creates a test user with a custom email address', () =>
|
|
85
|
-
.then((u) => {
|
|
91
|
+
it('creates a test user with a custom email address', () =>
|
|
92
|
+
createTestUser({emailAddress}).then((u) => {
|
|
86
93
|
assert.isTestUser(u);
|
|
87
94
|
assert.hasAccessToken(u);
|
|
88
95
|
assert.equal(u.email, emailAddress);
|
|
89
96
|
}));
|
|
90
97
|
|
|
91
|
-
it('creates a test user with a custom password', () =>
|
|
92
|
-
.then((u) => {
|
|
98
|
+
it('creates a test user with a custom password', () =>
|
|
99
|
+
createTestUser({password}).then((u) => {
|
|
93
100
|
assert.isTestUser(u);
|
|
94
101
|
assert.hasAccessToken(u);
|
|
95
102
|
assert.equal(u.password, password);
|
|
96
103
|
}));
|
|
97
104
|
|
|
98
|
-
it('creates a test user with a custom display name', () =>
|
|
99
|
-
.then((u) => {
|
|
105
|
+
it('creates a test user with a custom display name', () =>
|
|
106
|
+
createTestUser({displayName}).then((u) => {
|
|
100
107
|
assert.isTestUser(u);
|
|
101
108
|
assert.hasAccessToken(u);
|
|
102
109
|
assert.equal(u.displayName, displayName);
|
|
103
110
|
}));
|
|
104
111
|
|
|
105
|
-
it('creates a test user with a usable refresh token', () =>
|
|
106
|
-
.then(async (u) => {
|
|
112
|
+
it('creates a test user with a usable refresh token', () =>
|
|
113
|
+
createTestUser({}).then(async (u) => {
|
|
107
114
|
assert.isTestUser(u);
|
|
108
115
|
assert.hasAccessToken(u);
|
|
109
116
|
|
|
@@ -112,8 +119,8 @@ nodeOnly(describe)('test-users', () => {
|
|
|
112
119
|
assert.equal(res.statusCode, 200);
|
|
113
120
|
}));
|
|
114
121
|
|
|
115
|
-
it('creates a test user but returns an authorization code', () =>
|
|
116
|
-
.then((u) => {
|
|
122
|
+
it('creates a test user but returns an authorization code', () =>
|
|
123
|
+
createTestUser({authCodeOnly: true}).then((u) => {
|
|
117
124
|
assert.isTestUser(u);
|
|
118
125
|
assert.hasAuthorizationCode(u);
|
|
119
126
|
}));
|
|
@@ -121,70 +128,75 @@ nodeOnly(describe)('test-users', () => {
|
|
|
121
128
|
it('creates a test user in another org', async () => {
|
|
122
129
|
const u = await createTestUser({
|
|
123
130
|
orgId: 'kmsFederation',
|
|
124
|
-
entitlements: ['webExSquared']
|
|
131
|
+
entitlements: ['webExSquared'],
|
|
125
132
|
});
|
|
126
133
|
|
|
127
134
|
assert.isTestUser(u);
|
|
128
135
|
assert.hasAccessToken(u);
|
|
129
136
|
});
|
|
130
137
|
|
|
131
|
-
it('creates a machine type test user', () =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
it('creates a machine type test user', () =>
|
|
139
|
+
createTestUser({
|
|
140
|
+
machineType: 'LYRA_SPACE',
|
|
141
|
+
type: 'MACHINE',
|
|
142
|
+
}).then((u) => {
|
|
143
|
+
assert.isTestUser(u);
|
|
144
|
+
assert.equal(u.type, 'MACHINE', 'type is MACHINE');
|
|
145
|
+
assert.equal(u.machineType, 'LYRA_SPACE', 'machineType is LYRA_SPACE');
|
|
146
|
+
}));
|
|
139
147
|
});
|
|
140
148
|
|
|
141
149
|
describe('loginTestUser()', () => {
|
|
142
|
-
it('retrieves credentials for the specified user', () =>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
150
|
+
it('retrieves credentials for the specified user', () =>
|
|
151
|
+
createTestUser()
|
|
152
|
+
.then(prune)
|
|
153
|
+
.then(loginTestUser)
|
|
154
|
+
.then((token) => {
|
|
155
|
+
assert.hasAccessToken({token});
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
it('retrieves credentials with a useable refresh token', () =>
|
|
159
|
+
createTestUser()
|
|
160
|
+
.then(prune)
|
|
161
|
+
.then(loginTestUser)
|
|
162
|
+
.then(async (token) => {
|
|
163
|
+
assert.hasAccessToken({token});
|
|
164
|
+
assert.hasRefreshToken({token});
|
|
165
|
+
|
|
166
|
+
const res = await refresh({token});
|
|
167
|
+
|
|
168
|
+
assert.equal(res.statusCode, 200);
|
|
169
|
+
}));
|
|
160
170
|
});
|
|
161
171
|
|
|
162
172
|
describe('removeTestUser()', () => {
|
|
163
|
-
it('removes the specified test user', () =>
|
|
164
|
-
.then(async (u) => {
|
|
173
|
+
it('removes the specified test user', () =>
|
|
174
|
+
createTestUser().then(async (u) => {
|
|
165
175
|
const res = await removeTestUser(u);
|
|
166
176
|
|
|
167
177
|
assert.equal(res.statusCode, 204);
|
|
168
178
|
}));
|
|
169
179
|
|
|
170
|
-
it('removes a test user if no access token is available', () =>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
it('removes a test user if no access token is available', () =>
|
|
181
|
+
createTestUser()
|
|
182
|
+
.then(prune)
|
|
183
|
+
.then(async (u) => {
|
|
184
|
+
const res = await removeTestUser(u);
|
|
174
185
|
|
|
175
|
-
|
|
176
|
-
|
|
186
|
+
assert.equal(res.statusCode, 204);
|
|
187
|
+
}));
|
|
177
188
|
|
|
178
|
-
it('removes a test user with an access token set to undefined', () =>
|
|
179
|
-
|
|
180
|
-
user
|
|
189
|
+
it('removes a test user with an access token set to undefined', () =>
|
|
190
|
+
createTestUser()
|
|
191
|
+
.then((user) => {
|
|
192
|
+
user.token = undefined;
|
|
181
193
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
return user;
|
|
195
|
+
})
|
|
196
|
+
.then(async (u) => {
|
|
197
|
+
const res = await removeTestUser(u);
|
|
186
198
|
|
|
187
|
-
|
|
188
|
-
|
|
199
|
+
assert.equal(res.statusCode, 204);
|
|
200
|
+
}));
|
|
189
201
|
});
|
|
190
202
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import chai from 'chai';
|
|
3
2
|
import chaiAsPromised from 'chai-as-promised';
|
|
4
3
|
import {jenkinsOnly} from '@webex/test-helper-mocha';
|
|
@@ -22,16 +21,16 @@ assert.isTestUser = (user) => {
|
|
|
22
21
|
|
|
23
22
|
jenkinsOnly(describe)('test-users-whistler', () => {
|
|
24
23
|
describe('createWhistlerTestUser()', () => {
|
|
25
|
-
it('creates a test user', () =>
|
|
26
|
-
.then((u) => {
|
|
24
|
+
it('creates a test user', () =>
|
|
25
|
+
createWhistlerTestUser().then((u) => {
|
|
27
26
|
assert.isTestUser(u);
|
|
28
27
|
assert.hasAccessToken(u);
|
|
29
28
|
}));
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
describe('removeWhistlerTestUser()', () => {
|
|
33
|
-
it('removes the specified test user', () =>
|
|
34
|
-
.then(async (u) => {
|
|
32
|
+
it('removes the specified test user', () =>
|
|
33
|
+
createWhistlerTestUser().then(async (u) => {
|
|
35
34
|
const res = await removeWhistlerTestUser(u);
|
|
36
35
|
|
|
37
36
|
assert.equal(res.statusCode, 204);
|