@webex/webex-server 2.29.3 → 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.
- package/.eslintrc.js +6 -0
- package/babel.config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/dist/memory-store.js +12 -33
- package/dist/memory-store.js.map +1 -1
- package/dist/session.js +5 -35
- package/dist/session.js.map +1 -1
- package/dist/webex.js +0 -22
- package/dist/webex.js.map +1 -1
- package/jest.config.js +3 -0
- package/package.json +51 -31
- package/process +1 -0
- package/src/index.js +30 -19
- package/src/memory-store.js +44 -42
- package/src/session.js +71 -79
- package/test/integration/spec/session.js +148 -147
|
@@ -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', () =>
|
|
28
|
-
.put('/api/v1/session')
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
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(() =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
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(() =>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
user.id,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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(() =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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(() =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{url: conversation.url}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.then(() => agent
|
|
168
|
-
|
|
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(
|
|
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
|
-
|
|
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(() =>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
user.id,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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(() =>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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(() =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
{url: conversation.url}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
.then(() => agent
|
|
237
|
-
|
|
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
|
});
|