@webex/webex-server 2.59.2 → 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.
@@ -1,242 +1,242 @@
1
- import path from 'path';
2
-
3
- import {assert} from '@webex/test-helper-chai';
4
- import app from '@webex/webex-server';
5
- import request from 'supertest';
6
- import testUsers from '@webex/test-helper-test-users';
7
- import {nodeOnly} from '@webex/test-helper-mocha';
8
-
9
- /* eslint-disable camelcase */
10
- function expectSession(res) {
11
- const {webex} = res.body;
12
-
13
- assert.property(webex.credentials.supertoken, 'token_type');
14
- assert.property(webex.credentials.supertoken, 'access_token');
15
- assert.property(webex.credentials.supertoken, 'expires_in');
16
-
17
- assert.property(webex.credentials.supertoken, 'expires');
18
-
19
- assert.property(webex.internal.device, 'url');
20
- assert.property(webex.internal, 'services');
21
-
22
- return res;
23
- }
24
-
25
- nodeOnly(describe)('/api/v1/session', () => {
26
- describe('PUT', () => {
27
- it('requires a client_id', () =>
28
- request(app).put('/api/v1/session').expect(400).expect('clientId is missing'));
29
-
30
- it('requires a client_id', () =>
31
- request(app)
32
- .put('/api/v1/session')
33
- .send({clientId: 'not a real client'})
34
- .expect(400)
35
- .expect('clientSecret is missing'));
36
-
37
- it('requires a user with a token', () =>
38
- request(app)
39
- .put('/api/v1/session')
40
- .send({
41
- clientId: 'not a real client',
42
- clientSecret: 'not a real secret',
43
- redirectUri: process.env.WEBEX_REDIRECT_URI,
44
- scope: process.env.WEBEX_SCOPE,
45
- user: {},
46
- })
47
- .expect(400)
48
- .expect('user.token is missing'));
49
-
50
- it('authorizes a webex instance with the specified user', () => {
51
- const agent = request.agent(app);
52
-
53
- return testUsers.create({count: 1}).then(([user]) =>
54
- agent
55
- .put('/api/v1/session')
56
- .send({
57
- clientId: process.env.WEBEX_CLIENT_ID,
58
- clientSecret: process.env.WEBEX_CLIENT_SECRET,
59
- redirectUri: process.env.WEBEX_REDIRECT_URI,
60
- scope: process.env.WEBEX_SCOPE,
61
- user,
62
- })
63
- .expect(200)
64
- .expect(expectSession)
65
- .then(() => agent.get('/api/v1/session').expect(200).expect(expectSession))
66
- .then(() => agent.delete('/api/v1/session').expect(204))
67
- );
68
- });
69
- });
70
- });
71
-
72
- describe('/api/v1/session/invoke*', () => {
73
- describe('POST', () => {
74
- it('returns the result of the method at the specified keypath', () => {
75
- const agent = request.agent(app);
76
-
77
- return testUsers.create({count: 1}).then(([user]) =>
78
- agent
79
- .put('/api/v1/session')
80
- .send({
81
- clientId: process.env.WEBEX_CLIENT_ID,
82
- clientSecret: process.env.WEBEX_CLIENT_SECRET,
83
- redirectUri: process.env.WEBEX_REDIRECT_URI,
84
- scope: process.env.WEBEX_SCOPE,
85
- user,
86
- })
87
- .expect(200)
88
- .expect(expectSession)
89
- .then(() =>
90
- agent
91
- .post('/api/v1/session/invoke/internal/encryption/kms/createUnboundKeys')
92
- .send([{count: 1}])
93
- .expect(200)
94
- .expect((res) => {
95
- assert.isArray(res.body);
96
- assert.property(res.body[0], 'uri');
97
- assert.property(res.body[0], 'jwk');
98
- })
99
- )
100
- .then(() => agent.delete('/api/v1/session').expect(204))
101
- );
102
- });
103
-
104
- it('creates a conversation', () => {
105
- const agent = request.agent(app);
106
- let conversation;
107
-
108
- return testUsers.create({count: 3}).then(([user, ...users]) =>
109
- agent
110
- .put('/api/v1/session')
111
- .send({
112
- clientId: process.env.WEBEX_CLIENT_ID,
113
- clientSecret: process.env.WEBEX_CLIENT_SECRET,
114
- redirectUri: process.env.WEBEX_REDIRECT_URI,
115
- scope: process.env.WEBEX_SCOPE,
116
- user,
117
- })
118
- .expect(200)
119
- // Create a conversation
120
- .then(() =>
121
- agent
122
- .post('/api/v1/session/invoke/internal/conversation/create')
123
- .send([
124
- {
125
- comment: 'first message',
126
- displayName: 'title',
127
- participants: [user.id, users[0].id, users[1].id],
128
- },
129
- ])
130
- .expect(200)
131
- .expect((res) => {
132
- conversation = res.body;
133
- assert.property(conversation, 'objectType');
134
- assert.equal(conversation.objectType, 'conversation');
135
- })
136
- )
137
- // Send a message to the conversation
138
- .then(() =>
139
- agent
140
- .post('/api/v1/session/invoke/internal/conversation/post')
141
- .send([
142
- conversation,
143
- {
144
- displayName: 'second comment',
145
- },
146
- ])
147
- .expect(200)
148
- .expect((res) => {
149
- assert.property(res.body, 'objectType');
150
- assert.equal(res.body.objectType, 'activity');
151
- })
152
- )
153
- // Fetch the conversation
154
- .then(() =>
155
- agent
156
- .post('/api/v1/session/invoke/internal/conversation/get')
157
- .send([{url: conversation.url}])
158
- .expect(200)
159
- .expect((res) => {
160
- assert.property(res.body, 'objectType');
161
- assert.equal(res.body.objectType, 'conversation');
162
- })
163
- )
164
- .then(() => agent.delete('/api/v1/session').expect(204))
165
- );
166
- });
167
-
168
- it('post a file', () => {
169
- const agent = request.agent(app);
170
- const filepath = path.join(
171
- __dirname,
172
- '../../../../',
173
- 'test-helper-server/static/sample-image-small-one.png'
174
- );
175
- let conversation;
176
-
177
- return testUsers.create({count: 3}).then(([user, ...users]) =>
178
- agent
179
- .put('/api/v1/session')
180
- .send({
181
- clientId: process.env.WEBEX_CLIENT_ID,
182
- clientSecret: process.env.WEBEX_CLIENT_SECRET,
183
- redirectUri: process.env.WEBEX_REDIRECT_URI,
184
- scope: process.env.WEBEX_SCOPE,
185
- user,
186
- })
187
- .expect(200)
188
- // Create a conversation
189
- .then(() =>
190
- agent
191
- .post('/api/v1/session/invoke/internal/conversation/create')
192
- .send([
193
- {
194
- comment: 'first message',
195
- displayName: 'title',
196
- participants: [user.id, users[0].id, users[1].id],
197
- },
198
- ])
199
- .expect(200)
200
- .expect((res) => {
201
- conversation = res.body;
202
- assert.property(conversation, 'objectType');
203
- assert.equal(conversation.objectType, 'conversation');
204
- })
205
- )
206
- // Send a file to the conversation
207
- .then(() =>
208
- agent
209
- .post('/api/v1/session/invoke/internal/conversation/share')
210
- .send([
211
- conversation,
212
- {
213
- files: [
214
- {
215
- path: filepath,
216
- displayName: 'sample-image-small-one.png',
217
- },
218
- ],
219
- },
220
- ])
221
- .expect(200)
222
- .expect((res) => {
223
- assert.property(res.body, 'objectType');
224
- assert.equal(res.body.objectType, 'activity');
225
- })
226
- )
227
- // Fetch the conversation
228
- .then(() =>
229
- agent
230
- .post('/api/v1/session/invoke/internal/conversation/get')
231
- .send([{url: conversation.url}])
232
- .expect(200)
233
- .expect((res) => {
234
- assert.property(res.body, 'objectType');
235
- assert.equal(res.body.objectType, 'conversation');
236
- })
237
- )
238
- .then(() => agent.delete('/api/v1/session').expect(204))
239
- );
240
- });
241
- });
242
- });
1
+ import path from 'path';
2
+
3
+ import {assert} from '@webex/test-helper-chai';
4
+ import app from '@webex/webex-server';
5
+ import request from 'supertest';
6
+ import testUsers from '@webex/test-helper-test-users';
7
+ import {nodeOnly} from '@webex/test-helper-mocha';
8
+
9
+ /* eslint-disable camelcase */
10
+ function expectSession(res) {
11
+ const {webex} = res.body;
12
+
13
+ assert.property(webex.credentials.supertoken, 'token_type');
14
+ assert.property(webex.credentials.supertoken, 'access_token');
15
+ assert.property(webex.credentials.supertoken, 'expires_in');
16
+
17
+ assert.property(webex.credentials.supertoken, 'expires');
18
+
19
+ assert.property(webex.internal.device, 'url');
20
+ assert.property(webex.internal, 'services');
21
+
22
+ return res;
23
+ }
24
+
25
+ nodeOnly(describe)('/api/v1/session', () => {
26
+ describe('PUT', () => {
27
+ it('requires a client_id', () =>
28
+ request(app).put('/api/v1/session').expect(400).expect('clientId is missing'));
29
+
30
+ it('requires a client_id', () =>
31
+ request(app)
32
+ .put('/api/v1/session')
33
+ .send({clientId: 'not a real client'})
34
+ .expect(400)
35
+ .expect('clientSecret is missing'));
36
+
37
+ it('requires a user with a token', () =>
38
+ request(app)
39
+ .put('/api/v1/session')
40
+ .send({
41
+ clientId: 'not a real client',
42
+ clientSecret: 'not a real secret',
43
+ redirectUri: process.env.WEBEX_REDIRECT_URI,
44
+ scope: process.env.WEBEX_SCOPE,
45
+ user: {},
46
+ })
47
+ .expect(400)
48
+ .expect('user.token is missing'));
49
+
50
+ it('authorizes a webex instance with the specified user', () => {
51
+ const agent = request.agent(app);
52
+
53
+ return testUsers.create({count: 1}).then(([user]) =>
54
+ agent
55
+ .put('/api/v1/session')
56
+ .send({
57
+ clientId: process.env.WEBEX_CLIENT_ID,
58
+ clientSecret: process.env.WEBEX_CLIENT_SECRET,
59
+ redirectUri: process.env.WEBEX_REDIRECT_URI,
60
+ scope: process.env.WEBEX_SCOPE,
61
+ user,
62
+ })
63
+ .expect(200)
64
+ .expect(expectSession)
65
+ .then(() => agent.get('/api/v1/session').expect(200).expect(expectSession))
66
+ .then(() => agent.delete('/api/v1/session').expect(204))
67
+ );
68
+ });
69
+ });
70
+ });
71
+
72
+ describe('/api/v1/session/invoke*', () => {
73
+ describe('POST', () => {
74
+ it('returns the result of the method at the specified keypath', () => {
75
+ const agent = request.agent(app);
76
+
77
+ return testUsers.create({count: 1}).then(([user]) =>
78
+ agent
79
+ .put('/api/v1/session')
80
+ .send({
81
+ clientId: process.env.WEBEX_CLIENT_ID,
82
+ clientSecret: process.env.WEBEX_CLIENT_SECRET,
83
+ redirectUri: process.env.WEBEX_REDIRECT_URI,
84
+ scope: process.env.WEBEX_SCOPE,
85
+ user,
86
+ })
87
+ .expect(200)
88
+ .expect(expectSession)
89
+ .then(() =>
90
+ agent
91
+ .post('/api/v1/session/invoke/internal/encryption/kms/createUnboundKeys')
92
+ .send([{count: 1}])
93
+ .expect(200)
94
+ .expect((res) => {
95
+ assert.isArray(res.body);
96
+ assert.property(res.body[0], 'uri');
97
+ assert.property(res.body[0], 'jwk');
98
+ })
99
+ )
100
+ .then(() => agent.delete('/api/v1/session').expect(204))
101
+ );
102
+ });
103
+
104
+ it('creates a conversation', () => {
105
+ const agent = request.agent(app);
106
+ let conversation;
107
+
108
+ return testUsers.create({count: 3}).then(([user, ...users]) =>
109
+ agent
110
+ .put('/api/v1/session')
111
+ .send({
112
+ clientId: process.env.WEBEX_CLIENT_ID,
113
+ clientSecret: process.env.WEBEX_CLIENT_SECRET,
114
+ redirectUri: process.env.WEBEX_REDIRECT_URI,
115
+ scope: process.env.WEBEX_SCOPE,
116
+ user,
117
+ })
118
+ .expect(200)
119
+ // Create a conversation
120
+ .then(() =>
121
+ agent
122
+ .post('/api/v1/session/invoke/internal/conversation/create')
123
+ .send([
124
+ {
125
+ comment: 'first message',
126
+ displayName: 'title',
127
+ participants: [user.id, users[0].id, users[1].id],
128
+ },
129
+ ])
130
+ .expect(200)
131
+ .expect((res) => {
132
+ conversation = res.body;
133
+ assert.property(conversation, 'objectType');
134
+ assert.equal(conversation.objectType, 'conversation');
135
+ })
136
+ )
137
+ // Send a message to the conversation
138
+ .then(() =>
139
+ agent
140
+ .post('/api/v1/session/invoke/internal/conversation/post')
141
+ .send([
142
+ conversation,
143
+ {
144
+ displayName: 'second comment',
145
+ },
146
+ ])
147
+ .expect(200)
148
+ .expect((res) => {
149
+ assert.property(res.body, 'objectType');
150
+ assert.equal(res.body.objectType, 'activity');
151
+ })
152
+ )
153
+ // Fetch the conversation
154
+ .then(() =>
155
+ agent
156
+ .post('/api/v1/session/invoke/internal/conversation/get')
157
+ .send([{url: conversation.url}])
158
+ .expect(200)
159
+ .expect((res) => {
160
+ assert.property(res.body, 'objectType');
161
+ assert.equal(res.body.objectType, 'conversation');
162
+ })
163
+ )
164
+ .then(() => agent.delete('/api/v1/session').expect(204))
165
+ );
166
+ });
167
+
168
+ it('post a file', () => {
169
+ const agent = request.agent(app);
170
+ const filepath = path.join(
171
+ __dirname,
172
+ '../../../../',
173
+ 'test-helper-server/static/sample-image-small-one.png'
174
+ );
175
+ let conversation;
176
+
177
+ return testUsers.create({count: 3}).then(([user, ...users]) =>
178
+ agent
179
+ .put('/api/v1/session')
180
+ .send({
181
+ clientId: process.env.WEBEX_CLIENT_ID,
182
+ clientSecret: process.env.WEBEX_CLIENT_SECRET,
183
+ redirectUri: process.env.WEBEX_REDIRECT_URI,
184
+ scope: process.env.WEBEX_SCOPE,
185
+ user,
186
+ })
187
+ .expect(200)
188
+ // Create a conversation
189
+ .then(() =>
190
+ agent
191
+ .post('/api/v1/session/invoke/internal/conversation/create')
192
+ .send([
193
+ {
194
+ comment: 'first message',
195
+ displayName: 'title',
196
+ participants: [user.id, users[0].id, users[1].id],
197
+ },
198
+ ])
199
+ .expect(200)
200
+ .expect((res) => {
201
+ conversation = res.body;
202
+ assert.property(conversation, 'objectType');
203
+ assert.equal(conversation.objectType, 'conversation');
204
+ })
205
+ )
206
+ // Send a file to the conversation
207
+ .then(() =>
208
+ agent
209
+ .post('/api/v1/session/invoke/internal/conversation/share')
210
+ .send([
211
+ conversation,
212
+ {
213
+ files: [
214
+ {
215
+ path: filepath,
216
+ displayName: 'sample-image-small-one.png',
217
+ },
218
+ ],
219
+ },
220
+ ])
221
+ .expect(200)
222
+ .expect((res) => {
223
+ assert.property(res.body, 'objectType');
224
+ assert.equal(res.body.objectType, 'activity');
225
+ })
226
+ )
227
+ // Fetch the conversation
228
+ .then(() =>
229
+ agent
230
+ .post('/api/v1/session/invoke/internal/conversation/get')
231
+ .send([{url: conversation.url}])
232
+ .expect(200)
233
+ .expect((res) => {
234
+ assert.property(res.body, 'objectType');
235
+ assert.equal(res.body.objectType, 'conversation');
236
+ })
237
+ )
238
+ .then(() => agent.delete('/api/v1/session').expect(204))
239
+ );
240
+ });
241
+ });
242
+ });