@webex/test-helper-test-users 2.59.1 → 2.59.3-next.1
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/.eslintrc.js +6 -6
- package/README.md +88 -88
- package/babel.config.js +3 -3
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +13 -12
- package/process +1 -1
- package/src/index.js +130 -130
package/.eslintrc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
root: true,
|
|
3
|
-
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
module.exports = config;
|
|
1
|
+
const config = {
|
|
2
|
+
root: true,
|
|
3
|
+
extends: ['@webex/eslint-config-legacy'],
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
module.exports = config;
|
package/README.md
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
# @webex/test-helper-test-users
|
|
2
|
-
|
|
3
|
-
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
-
|
|
5
|
-
>
|
|
6
|
-
|
|
7
|
-
- [@webex/test-helper-test-users](#webextest-helper-test-users)
|
|
8
|
-
- [Install](#install)
|
|
9
|
-
- [Usage](#usage)
|
|
10
|
-
- [Environment Defaults](#environment-defaults)
|
|
11
|
-
- [Maintainers](#maintainers)
|
|
12
|
-
- [Contribute](#contribute)
|
|
13
|
-
- [License](#license)
|
|
14
|
-
|
|
15
|
-
## Install
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install --save @webex/test-helper-test-users
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
The `test-helper-test-users` package is a helper for [mocha](https://mochajs.org/) tests that handles the creation and deletion of test users in integration tests.
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
import webex from 'webex';
|
|
27
|
-
import testUsers from '@webex/test-helper-test-users';
|
|
28
|
-
|
|
29
|
-
describe('My Amazing Integration Test Suite', () => {
|
|
30
|
-
let testUserA, testUserB, testUserC;
|
|
31
|
-
|
|
32
|
-
before('create users', () => {
|
|
33
|
-
// Create Three Test Users
|
|
34
|
-
return testUsers.create({count: 3})
|
|
35
|
-
})
|
|
36
|
-
.then((createdTestUsers) => {
|
|
37
|
-
// Save the created test users
|
|
38
|
-
[testUserA, testUserB, testUserC] = createdTestUsers;
|
|
39
|
-
|
|
40
|
-
// Create a new sdk instance for the test user
|
|
41
|
-
testUserA.webex = webex.init({
|
|
42
|
-
config: {
|
|
43
|
-
credentials: {
|
|
44
|
-
authorization: testUserA.token
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('can do things with a test user', () => {
|
|
50
|
-
testUserA.people.get('me')
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Environment Defaults
|
|
55
|
-
|
|
56
|
-
The test users package defaults to certain environment variables if the values aren't specified in the "create" command. Those variables are:
|
|
57
|
-
|
|
58
|
-
- `WEBEX_CLIENT_ID` - The Webex client ID that has access to create test users
|
|
59
|
-
- `WEBEX_CLIENT_SECRET` - The Webex client secret for the given client id
|
|
60
|
-
- `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` - The Webex url for conversation service to create test users
|
|
61
|
-
- `WEBEX_SCOPE` - The Webex scope the test users should be created with
|
|
62
|
-
- `IDBROKER_BASE_URL` - The Webex auth endpoint to get a client based access token
|
|
63
|
-
|
|
64
|
-
These variables can been passed in to the `create` command as a `config` object as well:
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
const createConfig = {
|
|
68
|
-
clientId: mySpecificValue,
|
|
69
|
-
clientSecret: mySpecificValue,
|
|
70
|
-
idbrokerUrl: mySpecificValue,
|
|
71
|
-
cigServiceUrl: mySpecificValue,
|
|
72
|
-
scope: mySpecificValue,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
testUsers.create({config: createConfig});
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Maintainers
|
|
79
|
-
|
|
80
|
-
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
81
|
-
|
|
82
|
-
## Contribute
|
|
83
|
-
|
|
84
|
-
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
85
|
-
|
|
86
|
-
## License
|
|
87
|
-
|
|
88
|
-
© 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
|
|
1
|
+
# @webex/test-helper-test-users
|
|
2
|
+
|
|
3
|
+
[](https://github.com/RichardLitt/standard-readme)
|
|
4
|
+
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
- [@webex/test-helper-test-users](#webextest-helper-test-users)
|
|
8
|
+
- [Install](#install)
|
|
9
|
+
- [Usage](#usage)
|
|
10
|
+
- [Environment Defaults](#environment-defaults)
|
|
11
|
+
- [Maintainers](#maintainers)
|
|
12
|
+
- [Contribute](#contribute)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save @webex/test-helper-test-users
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
The `test-helper-test-users` package is a helper for [mocha](https://mochajs.org/) tests that handles the creation and deletion of test users in integration tests.
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import webex from 'webex';
|
|
27
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
28
|
+
|
|
29
|
+
describe('My Amazing Integration Test Suite', () => {
|
|
30
|
+
let testUserA, testUserB, testUserC;
|
|
31
|
+
|
|
32
|
+
before('create users', () => {
|
|
33
|
+
// Create Three Test Users
|
|
34
|
+
return testUsers.create({count: 3})
|
|
35
|
+
})
|
|
36
|
+
.then((createdTestUsers) => {
|
|
37
|
+
// Save the created test users
|
|
38
|
+
[testUserA, testUserB, testUserC] = createdTestUsers;
|
|
39
|
+
|
|
40
|
+
// Create a new sdk instance for the test user
|
|
41
|
+
testUserA.webex = webex.init({
|
|
42
|
+
config: {
|
|
43
|
+
credentials: {
|
|
44
|
+
authorization: testUserA.token
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('can do things with a test user', () => {
|
|
50
|
+
testUserA.people.get('me')
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Environment Defaults
|
|
55
|
+
|
|
56
|
+
The test users package defaults to certain environment variables if the values aren't specified in the "create" command. Those variables are:
|
|
57
|
+
|
|
58
|
+
- `WEBEX_CLIENT_ID` - The Webex client ID that has access to create test users
|
|
59
|
+
- `WEBEX_CLIENT_SECRET` - The Webex client secret for the given client id
|
|
60
|
+
- `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` - The Webex url for conversation service to create test users
|
|
61
|
+
- `WEBEX_SCOPE` - The Webex scope the test users should be created with
|
|
62
|
+
- `IDBROKER_BASE_URL` - The Webex auth endpoint to get a client based access token
|
|
63
|
+
|
|
64
|
+
These variables can been passed in to the `create` command as a `config` object as well:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const createConfig = {
|
|
68
|
+
clientId: mySpecificValue,
|
|
69
|
+
clientSecret: mySpecificValue,
|
|
70
|
+
idbrokerUrl: mySpecificValue,
|
|
71
|
+
cigServiceUrl: mySpecificValue,
|
|
72
|
+
scope: mySpecificValue,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
testUsers.create({config: createConfig});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Maintainers
|
|
79
|
+
|
|
80
|
+
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
81
|
+
|
|
82
|
+
## Contribute
|
|
83
|
+
|
|
84
|
+
Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
© 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
|
package/babel.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = babelConfigLegacy;
|
|
1
|
+
const babelConfigLegacy = require('@webex/babel-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = babelConfigLegacy;
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/
|
|
|
6
6
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
7
7
|
var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
|
|
8
8
|
/* eslint-disable no-underscore-dangle */
|
|
9
|
-
/*!
|
|
10
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
9
|
+
/*!
|
|
10
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/* eslint-env mocha */
|
|
@@ -33,15 +33,15 @@ if (after) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* Helper
|
|
38
|
-
* @param {Object} options
|
|
39
|
-
* @param {number} options.count amount of users to create
|
|
40
|
-
* @param {boolean} options.whistler use Whistler Service to generate test users
|
|
41
|
-
* @param {Object} options.config configuration to pass to test-users library
|
|
42
|
-
* see test-users package for full options
|
|
43
|
-
* @private
|
|
44
|
-
* @returns {Promise<Array<User>>}
|
|
36
|
+
/**
|
|
37
|
+
* Helper
|
|
38
|
+
* @param {Object} options
|
|
39
|
+
* @param {number} options.count amount of users to create
|
|
40
|
+
* @param {boolean} options.whistler use Whistler Service to generate test users
|
|
41
|
+
* @param {Object} options.config configuration to pass to test-users library
|
|
42
|
+
* see test-users package for full options
|
|
43
|
+
* @private
|
|
44
|
+
* @returns {Promise<Array<User>>}
|
|
45
45
|
*/
|
|
46
46
|
function _create(options) {
|
|
47
47
|
options = options || {};
|
|
@@ -56,10 +56,10 @@ function _create(options) {
|
|
|
56
56
|
}
|
|
57
57
|
return _promise.default.all(promises);
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Helper
|
|
61
|
-
* @private
|
|
62
|
-
* @returns {Promise<User>}
|
|
59
|
+
/**
|
|
60
|
+
* Helper
|
|
61
|
+
* @private
|
|
62
|
+
* @returns {Promise<User>}
|
|
63
63
|
*/
|
|
64
64
|
function makeUser() {
|
|
65
65
|
var config = _.defaults({
|
|
@@ -75,10 +75,10 @@ function _create(options) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* Helper
|
|
80
|
-
* @param {Array<User>} users
|
|
81
|
-
* @returns {Promise}
|
|
78
|
+
/**
|
|
79
|
+
* Helper
|
|
80
|
+
* @param {Array<User>} users
|
|
81
|
+
* @returns {Promise}
|
|
82
82
|
*/
|
|
83
83
|
function _remove(users) {
|
|
84
84
|
return _promise.default.all(users.map( /*#__PURE__*/function () {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["assert","require","_","retry","_require","createTestUser","removeTestUser","createWhistlerTestUser","removeWhistlerTestUser","allUsers","after","timeout","forEach","user","webex","internal","mercury","disconnect","_remove","_create","options","_options","count","promises","i","push","makeUser","_promise","default","all","config","defaults","scopes","process","env","WEBEX_SCOPE","whistler","then","users","map","_ref","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","reservationUrl","catch","reason","console","warn","token","authorization","_deleteProperty","abrupt","resolve","setTimeout","stop","_x","apply","arguments","module","exports","create","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","remove"],"sources":["index.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env mocha */\n/* eslint camelcase: [0] */\n\nconst assert = require('assert');\n\nconst _ = require('lodash');\nconst retry = require('@webex/test-helper-retry');\nconst {\n createTestUser,\n removeTestUser,\n createWhistlerTestUser,\n removeWhistlerTestUser,\n} = require('@webex/test-users');\n\nconst allUsers = [];\n\nif (after) {\n after(function () {\n /* eslint no-invalid-this: [0] */\n this.timeout(120000);\n allUsers.forEach(\n (user) =>\n user.webex && user.webex.internal.mercury && user.webex.internal.mercury.disconnect()\n );\n\n return _remove(allUsers);\n });\n}\n\n/**\n * Helper\n * @param {Object} options\n * @param {number} options.count amount of users to create\n * @param {boolean} options.whistler use Whistler Service to generate test users\n * @param {Object} options.config configuration to pass to test-users library\n * see test-users package for full options\n * @private\n * @returns {Promise<Array<User>>}\n */\nfunction _create(options) {\n options = options || {};\n let {count} = options;\n\n if (!count) {\n count = 1;\n }\n\n const promises = [];\n\n for (let i = 0; i < count; i += 1) {\n promises.push(retry(makeUser));\n }\n\n return Promise.all(promises);\n\n /**\n * Helper\n * @private\n * @returns {Promise<User>}\n */\n function makeUser() {\n const config = _.defaults(\n {\n scopes: process.env.WEBEX_SCOPE,\n },\n options.config\n );\n\n return options.whistler\n ? createWhistlerTestUser(config).then((user) => {\n allUsers.push(user);\n\n return user;\n })\n : createTestUser(config).then((user) => {\n allUsers.push(user);\n\n return user;\n });\n }\n}\n\n/**\n * Helper\n * @param {Array<User>} users\n * @returns {Promise}\n */\nfunction _remove(users) {\n return Promise.all(\n users.map(async (user) => {\n // Check if user was created using whistler\n if (user.reservationUrl) {\n await removeWhistlerTestUser(user).catch((reason) => {\n console.warn('failed to delete test user', reason);\n });\n } else {\n if (user.token && !user.token.authorization) {\n Reflect.deleteProperty(user, 'token');\n }\n\n await removeTestUser(user).catch((reason) => {\n console.warn('failed to delete test user', reason);\n });\n }\n\n // Edge times out waiting for the delete calls to complete (and test user\n // deletion isn't really something we need to wait for anyway) so we'll just\n // give enough time for the requests to go out, then allow the browser to\n // close, even if the requests haven't returned.\n return new Promise((resolve) => {\n setTimeout(resolve, 500);\n });\n })\n );\n}\n\nmodule.exports = {\n create: (options) => {\n assert(process.env.WEBEX_CLIENT_ID, 'WEBEX_CLIENT_ID must be defined');\n assert(process.env.WEBEX_CLIENT_SECRET, 'WEBEX_CLIENT_SECRET must be defined');\n\n return _create(options);\n },\n remove: _remove,\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,IAAMA,MAAM,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAEhC,IAAMC,CAAC,GAAGD,OAAO,CAAC,QAAQ,CAAC;AAC3B,IAAME,KAAK,GAAGF,OAAO,CAAC,0BAA0B,CAAC;AACjD,IAAAG,QAAA,GAKIH,OAAO,CAAC,mBAAmB,CAAC;EAJ9BI,cAAc,GAAAD,QAAA,CAAdC,cAAc;EACdC,cAAc,GAAAF,QAAA,CAAdE,cAAc;EACdC,sBAAsB,GAAAH,QAAA,CAAtBG,sBAAsB;EACtBC,sBAAsB,GAAAJ,QAAA,CAAtBI,sBAAsB;AAGxB,IAAMC,QAAQ,GAAG,EAAE;AAEnB,IAAIC,KAAK,EAAE;EACTA,KAAK,CAAC,YAAY;IAChB;IACA,IAAI,CAACC,OAAO,CAAC,MAAM,CAAC;IACpBF,QAAQ,CAACG,OAAO,CACd,UAACC,IAAI;MAAA,OACHA,IAAI,CAACC,KAAK,IAAID,IAAI,CAACC,KAAK,CAACC,QAAQ,CAACC,OAAO,IAAIH,IAAI,CAACC,KAAK,CAACC,QAAQ,CAACC,OAAO,CAACC,UAAU,EAAE;IAAA,EACxF;IAED,OAAOC,OAAO,CAACT,QAAQ,CAAC;EAC1B,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,OAAO,EAAK;IACnBpB,MAAM,CAACiC,OAAO,CAACC,GAAG,CAACkC,eAAe,EAAE,iCAAiC,CAAC;IACtEpE,MAAM,CAACiC,OAAO,CAACC,GAAG,CAACmC,mBAAmB,EAAE,qCAAqC,CAAC;IAE9E,OAAOlD,OAAO,CAACC,OAAO,CAAC;EACzB,CAAC;EACDkD,MAAM,EAAEpD;AACV,CAAC"}
|
|
1
|
+
{"version":3,"names":["assert","require","_","retry","_require","createTestUser","removeTestUser","createWhistlerTestUser","removeWhistlerTestUser","allUsers","after","timeout","forEach","user","webex","internal","mercury","disconnect","_remove","_create","options","_options","count","promises","i","push","makeUser","_promise","default","all","config","defaults","scopes","process","env","WEBEX_SCOPE","whistler","then","users","map","_ref","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","reservationUrl","catch","reason","console","warn","token","authorization","_deleteProperty","abrupt","resolve","setTimeout","stop","_x","apply","arguments","module","exports","create","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","remove"],"sources":["index.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\r\n/*!\r\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\r\n */\r\n\r\n/* eslint-env mocha */\r\n/* eslint camelcase: [0] */\r\n\r\nconst assert = require('assert');\r\n\r\nconst _ = require('lodash');\r\nconst retry = require('@webex/test-helper-retry');\r\nconst {\r\n createTestUser,\r\n removeTestUser,\r\n createWhistlerTestUser,\r\n removeWhistlerTestUser,\r\n} = require('@webex/test-users');\r\n\r\nconst allUsers = [];\r\n\r\nif (after) {\r\n after(function () {\r\n /* eslint no-invalid-this: [0] */\r\n this.timeout(120000);\r\n allUsers.forEach(\r\n (user) =>\r\n user.webex && user.webex.internal.mercury && user.webex.internal.mercury.disconnect()\r\n );\r\n\r\n return _remove(allUsers);\r\n });\r\n}\r\n\r\n/**\r\n * Helper\r\n * @param {Object} options\r\n * @param {number} options.count amount of users to create\r\n * @param {boolean} options.whistler use Whistler Service to generate test users\r\n * @param {Object} options.config configuration to pass to test-users library\r\n * see test-users package for full options\r\n * @private\r\n * @returns {Promise<Array<User>>}\r\n */\r\nfunction _create(options) {\r\n options = options || {};\r\n let {count} = options;\r\n\r\n if (!count) {\r\n count = 1;\r\n }\r\n\r\n const promises = [];\r\n\r\n for (let i = 0; i < count; i += 1) {\r\n promises.push(retry(makeUser));\r\n }\r\n\r\n return Promise.all(promises);\r\n\r\n /**\r\n * Helper\r\n * @private\r\n * @returns {Promise<User>}\r\n */\r\n function makeUser() {\r\n const config = _.defaults(\r\n {\r\n scopes: process.env.WEBEX_SCOPE,\r\n },\r\n options.config\r\n );\r\n\r\n return options.whistler\r\n ? createWhistlerTestUser(config).then((user) => {\r\n allUsers.push(user);\r\n\r\n return user;\r\n })\r\n : createTestUser(config).then((user) => {\r\n allUsers.push(user);\r\n\r\n return user;\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper\r\n * @param {Array<User>} users\r\n * @returns {Promise}\r\n */\r\nfunction _remove(users) {\r\n return Promise.all(\r\n users.map(async (user) => {\r\n // Check if user was created using whistler\r\n if (user.reservationUrl) {\r\n await removeWhistlerTestUser(user).catch((reason) => {\r\n console.warn('failed to delete test user', reason);\r\n });\r\n } else {\r\n if (user.token && !user.token.authorization) {\r\n Reflect.deleteProperty(user, 'token');\r\n }\r\n\r\n await removeTestUser(user).catch((reason) => {\r\n console.warn('failed to delete test user', reason);\r\n });\r\n }\r\n\r\n // Edge times out waiting for the delete calls to complete (and test user\r\n // deletion isn't really something we need to wait for anyway) so we'll just\r\n // give enough time for the requests to go out, then allow the browser to\r\n // close, even if the requests haven't returned.\r\n return new Promise((resolve) => {\r\n setTimeout(resolve, 500);\r\n });\r\n })\r\n );\r\n}\r\n\r\nmodule.exports = {\r\n create: (options) => {\r\n assert(process.env.WEBEX_CLIENT_ID, 'WEBEX_CLIENT_ID must be defined');\r\n assert(process.env.WEBEX_CLIENT_SECRET, 'WEBEX_CLIENT_SECRET must be defined');\r\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('@webex/jest-config-legacy');
|
|
2
|
-
|
|
3
|
-
module.exports = config;
|
|
1
|
+
const config = require('@webex/jest-config-legacy');
|
|
2
|
+
|
|
3
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/test-helper-test-users",
|
|
3
|
-
"version": "2.59.1",
|
|
4
3
|
"description": "",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"main": "dist/index.js",
|
|
@@ -21,13 +20,14 @@
|
|
|
21
20
|
]
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@webex/test-helper-retry": "2.59.1",
|
|
25
|
-
"@webex/test-users": "2.59.1",
|
|
23
|
+
"@webex/test-helper-retry": "^2.59.3-next.1",
|
|
24
|
+
"@webex/test-users": "^2.59.3-next.1",
|
|
26
25
|
"lodash": "^4.17.21"
|
|
27
26
|
},
|
|
28
27
|
"scripts": {
|
|
29
28
|
"build": "yarn build:src",
|
|
30
29
|
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
|
|
30
|
+
"deploy:npm": "yarn npm publish",
|
|
31
31
|
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
32
32
|
"test:browser": "webex-legacy-tools test --integration --unit --runner karma",
|
|
33
33
|
"test:integration": "webex-legacy-tools test --integration --runner mocha",
|
|
@@ -36,14 +36,15 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@babel/core": "^7.17.10",
|
|
39
|
-
"@webex/babel-config-legacy": "
|
|
40
|
-
"@webex/eslint-config-legacy": "
|
|
41
|
-
"@webex/jest-config-legacy": "
|
|
42
|
-
"@webex/legacy-tools": "
|
|
43
|
-
"@webex/test-helper-chai": "2.59.1",
|
|
44
|
-
"@webex/test-helper-mocha": "2.59.1",
|
|
45
|
-
"@webex/test-helper-mock-webex": "2.59.1",
|
|
39
|
+
"@webex/babel-config-legacy": "^0.0.0",
|
|
40
|
+
"@webex/eslint-config-legacy": "^0.0.0",
|
|
41
|
+
"@webex/jest-config-legacy": "^0.0.0",
|
|
42
|
+
"@webex/legacy-tools": "^0.0.0",
|
|
43
|
+
"@webex/test-helper-chai": "^2.59.3-next.1",
|
|
44
|
+
"@webex/test-helper-mocha": "^2.59.3-next.1",
|
|
45
|
+
"@webex/test-helper-mock-webex": "^2.59.3-next.1",
|
|
46
46
|
"eslint": "^8.24.0",
|
|
47
47
|
"prettier": "^2.7.1"
|
|
48
|
-
}
|
|
49
|
-
|
|
48
|
+
},
|
|
49
|
+
"version": "2.59.3-next.1"
|
|
50
|
+
}
|
package/process
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = {browser: true};
|
|
1
|
+
module.exports = {browser: true};
|
package/src/index.js
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
/* eslint-disable no-underscore-dangle */
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* eslint-env mocha */
|
|
7
|
-
/* eslint camelcase: [0] */
|
|
8
|
-
|
|
9
|
-
const assert = require('assert');
|
|
10
|
-
|
|
11
|
-
const _ = require('lodash');
|
|
12
|
-
const retry = require('@webex/test-helper-retry');
|
|
13
|
-
const {
|
|
14
|
-
createTestUser,
|
|
15
|
-
removeTestUser,
|
|
16
|
-
createWhistlerTestUser,
|
|
17
|
-
removeWhistlerTestUser,
|
|
18
|
-
} = require('@webex/test-users');
|
|
19
|
-
|
|
20
|
-
const allUsers = [];
|
|
21
|
-
|
|
22
|
-
if (after) {
|
|
23
|
-
after(function () {
|
|
24
|
-
/* eslint no-invalid-this: [0] */
|
|
25
|
-
this.timeout(120000);
|
|
26
|
-
allUsers.forEach(
|
|
27
|
-
(user) =>
|
|
28
|
-
user.webex && user.webex.internal.mercury && user.webex.internal.mercury.disconnect()
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return _remove(allUsers);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Helper
|
|
37
|
-
* @param {Object} options
|
|
38
|
-
* @param {number} options.count amount of users to create
|
|
39
|
-
* @param {boolean} options.whistler use Whistler Service to generate test users
|
|
40
|
-
* @param {Object} options.config configuration to pass to test-users library
|
|
41
|
-
* see test-users package for full options
|
|
42
|
-
* @private
|
|
43
|
-
* @returns {Promise<Array<User>>}
|
|
44
|
-
*/
|
|
45
|
-
function _create(options) {
|
|
46
|
-
options = options || {};
|
|
47
|
-
let {count} = options;
|
|
48
|
-
|
|
49
|
-
if (!count) {
|
|
50
|
-
count = 1;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const promises = [];
|
|
54
|
-
|
|
55
|
-
for (let i = 0; i < count; i += 1) {
|
|
56
|
-
promises.push(retry(makeUser));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return Promise.all(promises);
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Helper
|
|
63
|
-
* @private
|
|
64
|
-
* @returns {Promise<User>}
|
|
65
|
-
*/
|
|
66
|
-
function makeUser() {
|
|
67
|
-
const config = _.defaults(
|
|
68
|
-
{
|
|
69
|
-
scopes: process.env.WEBEX_SCOPE,
|
|
70
|
-
},
|
|
71
|
-
options.config
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return options.whistler
|
|
75
|
-
? createWhistlerTestUser(config).then((user) => {
|
|
76
|
-
allUsers.push(user);
|
|
77
|
-
|
|
78
|
-
return user;
|
|
79
|
-
})
|
|
80
|
-
: createTestUser(config).then((user) => {
|
|
81
|
-
allUsers.push(user);
|
|
82
|
-
|
|
83
|
-
return user;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Helper
|
|
90
|
-
* @param {Array<User>} users
|
|
91
|
-
* @returns {Promise}
|
|
92
|
-
*/
|
|
93
|
-
function _remove(users) {
|
|
94
|
-
return Promise.all(
|
|
95
|
-
users.map(async (user) => {
|
|
96
|
-
// Check if user was created using whistler
|
|
97
|
-
if (user.reservationUrl) {
|
|
98
|
-
await removeWhistlerTestUser(user).catch((reason) => {
|
|
99
|
-
console.warn('failed to delete test user', reason);
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
if (user.token && !user.token.authorization) {
|
|
103
|
-
Reflect.deleteProperty(user, 'token');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
await removeTestUser(user).catch((reason) => {
|
|
107
|
-
console.warn('failed to delete test user', reason);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Edge times out waiting for the delete calls to complete (and test user
|
|
112
|
-
// deletion isn't really something we need to wait for anyway) so we'll just
|
|
113
|
-
// give enough time for the requests to go out, then allow the browser to
|
|
114
|
-
// close, even if the requests haven't returned.
|
|
115
|
-
return new Promise((resolve) => {
|
|
116
|
-
setTimeout(resolve, 500);
|
|
117
|
-
});
|
|
118
|
-
})
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = {
|
|
123
|
-
create: (options) => {
|
|
124
|
-
assert(process.env.WEBEX_CLIENT_ID, 'WEBEX_CLIENT_ID must be defined');
|
|
125
|
-
assert(process.env.WEBEX_CLIENT_SECRET, 'WEBEX_CLIENT_SECRET must be defined');
|
|
126
|
-
|
|
127
|
-
return _create(options);
|
|
128
|
-
},
|
|
129
|
-
remove: _remove,
|
|
130
|
-
};
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-env mocha */
|
|
7
|
+
/* eslint camelcase: [0] */
|
|
8
|
+
|
|
9
|
+
const assert = require('assert');
|
|
10
|
+
|
|
11
|
+
const _ = require('lodash');
|
|
12
|
+
const retry = require('@webex/test-helper-retry');
|
|
13
|
+
const {
|
|
14
|
+
createTestUser,
|
|
15
|
+
removeTestUser,
|
|
16
|
+
createWhistlerTestUser,
|
|
17
|
+
removeWhistlerTestUser,
|
|
18
|
+
} = require('@webex/test-users');
|
|
19
|
+
|
|
20
|
+
const allUsers = [];
|
|
21
|
+
|
|
22
|
+
if (after) {
|
|
23
|
+
after(function () {
|
|
24
|
+
/* eslint no-invalid-this: [0] */
|
|
25
|
+
this.timeout(120000);
|
|
26
|
+
allUsers.forEach(
|
|
27
|
+
(user) =>
|
|
28
|
+
user.webex && user.webex.internal.mercury && user.webex.internal.mercury.disconnect()
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return _remove(allUsers);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Helper
|
|
37
|
+
* @param {Object} options
|
|
38
|
+
* @param {number} options.count amount of users to create
|
|
39
|
+
* @param {boolean} options.whistler use Whistler Service to generate test users
|
|
40
|
+
* @param {Object} options.config configuration to pass to test-users library
|
|
41
|
+
* see test-users package for full options
|
|
42
|
+
* @private
|
|
43
|
+
* @returns {Promise<Array<User>>}
|
|
44
|
+
*/
|
|
45
|
+
function _create(options) {
|
|
46
|
+
options = options || {};
|
|
47
|
+
let {count} = options;
|
|
48
|
+
|
|
49
|
+
if (!count) {
|
|
50
|
+
count = 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const promises = [];
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < count; i += 1) {
|
|
56
|
+
promises.push(retry(makeUser));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return Promise.all(promises);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Helper
|
|
63
|
+
* @private
|
|
64
|
+
* @returns {Promise<User>}
|
|
65
|
+
*/
|
|
66
|
+
function makeUser() {
|
|
67
|
+
const config = _.defaults(
|
|
68
|
+
{
|
|
69
|
+
scopes: process.env.WEBEX_SCOPE,
|
|
70
|
+
},
|
|
71
|
+
options.config
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return options.whistler
|
|
75
|
+
? createWhistlerTestUser(config).then((user) => {
|
|
76
|
+
allUsers.push(user);
|
|
77
|
+
|
|
78
|
+
return user;
|
|
79
|
+
})
|
|
80
|
+
: createTestUser(config).then((user) => {
|
|
81
|
+
allUsers.push(user);
|
|
82
|
+
|
|
83
|
+
return user;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Helper
|
|
90
|
+
* @param {Array<User>} users
|
|
91
|
+
* @returns {Promise}
|
|
92
|
+
*/
|
|
93
|
+
function _remove(users) {
|
|
94
|
+
return Promise.all(
|
|
95
|
+
users.map(async (user) => {
|
|
96
|
+
// Check if user was created using whistler
|
|
97
|
+
if (user.reservationUrl) {
|
|
98
|
+
await removeWhistlerTestUser(user).catch((reason) => {
|
|
99
|
+
console.warn('failed to delete test user', reason);
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
if (user.token && !user.token.authorization) {
|
|
103
|
+
Reflect.deleteProperty(user, 'token');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
await removeTestUser(user).catch((reason) => {
|
|
107
|
+
console.warn('failed to delete test user', reason);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Edge times out waiting for the delete calls to complete (and test user
|
|
112
|
+
// deletion isn't really something we need to wait for anyway) so we'll just
|
|
113
|
+
// give enough time for the requests to go out, then allow the browser to
|
|
114
|
+
// close, even if the requests haven't returned.
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
setTimeout(resolve, 500);
|
|
117
|
+
});
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
create: (options) => {
|
|
124
|
+
assert(process.env.WEBEX_CLIENT_ID, 'WEBEX_CLIENT_ID must be defined');
|
|
125
|
+
assert(process.env.WEBEX_CLIENT_SECRET, 'WEBEX_CLIENT_SECRET must be defined');
|
|
126
|
+
|
|
127
|
+
return _create(options);
|
|
128
|
+
},
|
|
129
|
+
remove: _remove,
|
|
130
|
+
};
|