@webex/webex-server 2.29.2 → 2.52.7

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