@tiledesk/tiledesk-server 3.3.5 → 3.5.0
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/CHANGELOG.md +17 -0
- package/app.js +7 -0
- package/docs/activities-client.md +27 -0
- package/docs/mcp-oauth2-it.md +279 -0
- package/docs/mcp-oauth2.md +279 -0
- package/docs/superpowers/plans/2026-11-10-mcp-oauth2-server-it.md +155 -0
- package/docs/superpowers/plans/2026-11-10-mcp-oauth2-server.md +155 -0
- package/docs/superpowers/plans/2026-11-10-mcp-oauth2-tybot-it.md +63 -0
- package/docs/superpowers/plans/2026-11-10-mcp-oauth2-tybot.md +63 -0
- package/docs/superpowers/specs/2026-11-10-mcp-oauth2-design-it.md +207 -0
- package/docs/superpowers/specs/2026-11-10-mcp-oauth2-design.md +207 -0
- package/jobs.js +15 -0
- package/models/mcpOAuthConnection.js +131 -0
- package/package.json +1 -1
- package/pubmodules/activities/activityMessageUtil.js +137 -0
- package/pubmodules/activities/models/activity.js +2 -0
- package/pubmodules/activities/routes/activity.js +30 -1
- package/pubmodules/activities/test/execution-filter.test.js +133 -0
- package/pubmodules/activities/test/execution-messages.test.js +158 -0
- package/pubmodules/executions-publisher/index.js +457 -0
- package/pubmodules/executions-publisher/test/audit-consumer.test.js +384 -0
- package/pubmodules/executions-publisher/test/executions-publisher.test.js +204 -0
- package/pubmodules/pubModulesManager.js +12 -0
- package/routes/executions-refire.js +148 -0
- package/routes/mcp.js +11 -8
- package/routes/mcpOAuth.js +133 -0
- package/routes/mcpOAuthCallback.js +75 -0
- package/routes/request.js +5 -0
- package/routes/webhook.js +120 -54
- package/services/mcpOAuthDiscovery.js +248 -0
- package/services/mcpOAuthGoogleScopes.js +55 -0
- package/services/mcpOAuthService.js +732 -0
- package/services/mcpService.js +111 -15
- package/services/requestService.js +4 -2
- package/services/webhookService.js +4 -2
- package/test/executions-refire.test.js +362 -0
- package/test/mcpOAuthDiscovery.test.js +331 -0
- package/test/mcpOAuthGoogleScopes.test.js +25 -0
- package/test/mcpOAuthRoute.test.js +455 -0
- package/test/mcpOAuthService.test.js +693 -0
- package/test/mcpOAuthUtils.test.js +348 -0
- package/test/mcpServiceOAuth.test.js +267 -0
- package/test/requestRoute.js +57 -0
- package/test/webhookConversationRoute.js +51 -0
- package/utils/logRedactor.js +4 -2
- package/utils/mcpOAuthCrypto.js +69 -0
- package/utils/mcpOAuthPkce.js +20 -0
- package/utils/outboundUrlGuard.js +131 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
const dns = require('dns');
|
|
3
|
+
const nock = require('nock');
|
|
4
|
+
|
|
5
|
+
const discovery = require('../services/mcpOAuthDiscovery');
|
|
6
|
+
|
|
7
|
+
const MCP_ORIGIN = 'https://mcp.example.com';
|
|
8
|
+
const AUTH_ORIGIN = 'https://auth.example.com';
|
|
9
|
+
const SERVER_URL = MCP_ORIGIN + '/mcp';
|
|
10
|
+
const REDIRECT_URI = 'https://api.tiledesk.test/oauth2/mcp/callback';
|
|
11
|
+
|
|
12
|
+
const AS_METADATA = {
|
|
13
|
+
issuer: AUTH_ORIGIN,
|
|
14
|
+
authorization_endpoint: AUTH_ORIGIN + '/authorize',
|
|
15
|
+
token_endpoint: AUTH_ORIGIN + '/token',
|
|
16
|
+
registration_endpoint: AUTH_ORIGIN + '/register',
|
|
17
|
+
revocation_endpoint: AUTH_ORIGIN + '/revoke',
|
|
18
|
+
code_challenge_methods_supported: ['S256'],
|
|
19
|
+
token_endpoint_auth_methods_supported: ['client_secret_post', 'none']
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function unauthorized(wwwAuthenticate) {
|
|
23
|
+
const headers = wwwAuthenticate ? { 'WWW-Authenticate': wwwAuthenticate } : {};
|
|
24
|
+
return nock(MCP_ORIGIN)
|
|
25
|
+
.post('/mcp', (body) => body.method === 'initialize' && body.jsonrpc === '2.0')
|
|
26
|
+
.reply(401, { error: 'invalid_token' }, headers);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function rejection(promise) {
|
|
30
|
+
try {
|
|
31
|
+
await promise;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('expected a rejection');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('mcpOAuthDiscovery', () => {
|
|
39
|
+
let originalLookup;
|
|
40
|
+
let originalInsecure;
|
|
41
|
+
|
|
42
|
+
before(() => {
|
|
43
|
+
nock.disableNetConnect();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
after(() => {
|
|
47
|
+
nock.enableNetConnect();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
originalLookup = dns.promises.lookup;
|
|
52
|
+
dns.promises.lookup = async () => [{ address: '93.184.216.34', family: 4 }];
|
|
53
|
+
originalInsecure = process.env.MCP_OAUTH_ALLOW_INSECURE_URLS;
|
|
54
|
+
delete process.env.MCP_OAUTH_ALLOW_INSECURE_URLS;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
dns.promises.lookup = originalLookup;
|
|
59
|
+
if (originalInsecure === undefined) {
|
|
60
|
+
delete process.env.MCP_OAUTH_ALLOW_INSECURE_URLS;
|
|
61
|
+
} else {
|
|
62
|
+
process.env.MCP_OAUTH_ALLOW_INSECURE_URLS = originalInsecure;
|
|
63
|
+
}
|
|
64
|
+
const pending = nock.pendingMocks();
|
|
65
|
+
nock.cleanAll();
|
|
66
|
+
expect(pending, 'unused nock interceptors').to.deep.equal([]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('well-known URLs', () => {
|
|
70
|
+
|
|
71
|
+
it('inserts the path before the root URL', () => {
|
|
72
|
+
expect(discovery.wellKnownUrls('https://a.com/tenant1/', 'oauth-protected-resource')).to.deep.equal([
|
|
73
|
+
'https://a.com/.well-known/oauth-protected-resource/tenant1',
|
|
74
|
+
'https://a.com/.well-known/oauth-protected-resource'
|
|
75
|
+
]);
|
|
76
|
+
expect(discovery.wellKnownUrls('https://a.com', 'oauth-authorization-server')).to.deep.equal([
|
|
77
|
+
'https://a.com/.well-known/oauth-authorization-server'
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('lists OAuth then OpenID metadata for an issuer with a path', () => {
|
|
82
|
+
expect(discovery.authorizationServerMetadataUrls('https://auth.example.com/tenant1')).to.deep.equal([
|
|
83
|
+
'https://auth.example.com/.well-known/oauth-authorization-server/tenant1',
|
|
84
|
+
'https://auth.example.com/.well-known/oauth-authorization-server',
|
|
85
|
+
'https://auth.example.com/.well-known/openid-configuration/tenant1',
|
|
86
|
+
'https://auth.example.com/tenant1/.well-known/openid-configuration',
|
|
87
|
+
'https://auth.example.com/.well-known/openid-configuration'
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('parses resource_metadata and scope from WWW-Authenticate', () => {
|
|
92
|
+
expect(discovery.parseWwwAuthenticate('Bearer error="invalid_token", resource_metadata="https://x/.well-known/oauth-protected-resource", scope="read write"'))
|
|
93
|
+
.to.deep.equal({ resource_metadata: 'https://x/.well-known/oauth-protected-resource', scope: 'read write' });
|
|
94
|
+
expect(discovery.parseWwwAuthenticate(undefined)).to.deep.equal({});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('discover', () => {
|
|
99
|
+
|
|
100
|
+
it('follows resource_metadata from the 401 challenge', async () => {
|
|
101
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/.well-known/oauth-protected-resource/mcp"');
|
|
102
|
+
nock(MCP_ORIGIN).get('/.well-known/oauth-protected-resource/mcp')
|
|
103
|
+
.reply(200, { resource: SERVER_URL, authorization_servers: [AUTH_ORIGIN], scopes_supported: ['mcp:tools'] });
|
|
104
|
+
nock(AUTH_ORIGIN).get('/.well-known/oauth-authorization-server').reply(200, AS_METADATA);
|
|
105
|
+
|
|
106
|
+
const result = await discovery.discover(SERVER_URL);
|
|
107
|
+
|
|
108
|
+
expect(result).to.deep.equal({
|
|
109
|
+
resource: SERVER_URL,
|
|
110
|
+
issuer: AUTH_ORIGIN,
|
|
111
|
+
authorization_endpoint: AUTH_ORIGIN + '/authorize',
|
|
112
|
+
token_endpoint: AUTH_ORIGIN + '/token',
|
|
113
|
+
revocation_endpoint: AUTH_ORIGIN + '/revoke',
|
|
114
|
+
registration_endpoint: AUTH_ORIGIN + '/register',
|
|
115
|
+
scopes_supported: ['mcp:tools'],
|
|
116
|
+
token_endpoint_auth_methods_supported: ['client_secret_post', 'none']
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('tries the path-inserted then the root well-known URL without a challenge header', async () => {
|
|
121
|
+
unauthorized();
|
|
122
|
+
nock(MCP_ORIGIN).get('/.well-known/oauth-protected-resource/mcp').reply(404);
|
|
123
|
+
nock(MCP_ORIGIN).get('/.well-known/oauth-protected-resource')
|
|
124
|
+
.reply(200, { resource: MCP_ORIGIN + '/', authorization_servers: [AUTH_ORIGIN] });
|
|
125
|
+
nock(AUTH_ORIGIN).get('/.well-known/oauth-authorization-server').reply(200, AS_METADATA);
|
|
126
|
+
|
|
127
|
+
const result = await discovery.discover(SERVER_URL);
|
|
128
|
+
|
|
129
|
+
expect(result.resource).to.equal(MCP_ORIGIN + '/');
|
|
130
|
+
expect(result.token_endpoint).to.equal(AUTH_ORIGIN + '/token');
|
|
131
|
+
expect(result).to.not.have.property('scopes_supported');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('prefers the scope of the challenge over scopes_supported', async () => {
|
|
135
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm", scope="files:read"');
|
|
136
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { authorization_servers: [AUTH_ORIGIN], scopes_supported: ['a', 'b'] });
|
|
137
|
+
nock(AUTH_ORIGIN).get('/.well-known/oauth-authorization-server').reply(200, AS_METADATA);
|
|
138
|
+
|
|
139
|
+
const result = await discovery.discover(SERVER_URL);
|
|
140
|
+
|
|
141
|
+
expect(result.scopes_supported).to.deep.equal(['files:read']);
|
|
142
|
+
expect(result.resource).to.equal(SERVER_URL);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('falls back to OpenID configuration for an issuer with a path', async () => {
|
|
146
|
+
const issuer = AUTH_ORIGIN + '/tenant1';
|
|
147
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm"');
|
|
148
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { authorization_servers: [issuer] });
|
|
149
|
+
nock(AUTH_ORIGIN)
|
|
150
|
+
.get('/.well-known/oauth-authorization-server/tenant1').reply(404)
|
|
151
|
+
.get('/.well-known/oauth-authorization-server').reply(404)
|
|
152
|
+
.get('/.well-known/openid-configuration/tenant1').reply(404)
|
|
153
|
+
.get('/tenant1/.well-known/openid-configuration')
|
|
154
|
+
.reply(200, { ...AS_METADATA, issuer, authorization_endpoint: issuer + '/authorize', token_endpoint: issuer + '/token' });
|
|
155
|
+
|
|
156
|
+
const result = await discovery.discover(SERVER_URL);
|
|
157
|
+
|
|
158
|
+
expect(result.issuer).to.equal(issuer);
|
|
159
|
+
expect(result.authorization_endpoint).to.equal(issuer + '/authorize');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('uses the MCP server origin as issuer when there is no resource metadata', async () => {
|
|
163
|
+
unauthorized();
|
|
164
|
+
nock(MCP_ORIGIN)
|
|
165
|
+
.get('/.well-known/oauth-protected-resource/mcp').reply(404)
|
|
166
|
+
.get('/.well-known/oauth-protected-resource').reply(404)
|
|
167
|
+
.get('/.well-known/oauth-authorization-server')
|
|
168
|
+
.reply(200, { ...AS_METADATA, issuer: MCP_ORIGIN, authorization_endpoint: MCP_ORIGIN + '/authorize', token_endpoint: MCP_ORIGIN + '/token' });
|
|
169
|
+
|
|
170
|
+
const result = await discovery.discover(SERVER_URL);
|
|
171
|
+
|
|
172
|
+
expect(result.issuer).to.equal(MCP_ORIGIN);
|
|
173
|
+
expect(result.resource).to.equal(SERVER_URL);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('fails when the server answers without authentication', async () => {
|
|
177
|
+
nock(MCP_ORIGIN).post('/mcp').reply(200, { jsonrpc: '2.0', id: 1, result: {} });
|
|
178
|
+
|
|
179
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
180
|
+
|
|
181
|
+
expect(error.status).to.equal(400);
|
|
182
|
+
expect(error.message).to.equal('This MCP server does not require OAuth');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('fails when no authorization server metadata is found', async () => {
|
|
186
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm"');
|
|
187
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { authorization_servers: [AUTH_ORIGIN] });
|
|
188
|
+
nock(AUTH_ORIGIN)
|
|
189
|
+
.get('/.well-known/oauth-authorization-server').reply(404)
|
|
190
|
+
.get('/.well-known/openid-configuration').reply(404);
|
|
191
|
+
|
|
192
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
193
|
+
|
|
194
|
+
expect(error.status).to.equal(400);
|
|
195
|
+
expect(error.message).to.equal('OAuth metadata not found for ' + SERVER_URL);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('fails when the authorization server does not support PKCE S256', async () => {
|
|
199
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm"');
|
|
200
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { authorization_servers: [AUTH_ORIGIN] });
|
|
201
|
+
nock(AUTH_ORIGIN).get('/.well-known/oauth-authorization-server')
|
|
202
|
+
.reply(200, { ...AS_METADATA, code_challenge_methods_supported: ['plain'] });
|
|
203
|
+
|
|
204
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
205
|
+
|
|
206
|
+
expect(error.status).to.equal(400);
|
|
207
|
+
expect(error.message).to.equal('Authorization server does not support PKCE S256');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('rejects resource metadata issued for another server', async () => {
|
|
211
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm"');
|
|
212
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { resource: 'https://other.example.com/mcp', authorization_servers: [AUTH_ORIGIN] });
|
|
213
|
+
|
|
214
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
215
|
+
|
|
216
|
+
expect(error.status).to.equal(400);
|
|
217
|
+
expect(error.message).to.contain('another server');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('rejects an authorization endpoint that is not https', async () => {
|
|
221
|
+
unauthorized('Bearer resource_metadata="' + MCP_ORIGIN + '/prm"');
|
|
222
|
+
nock(MCP_ORIGIN).get('/prm').reply(200, { authorization_servers: [AUTH_ORIGIN] });
|
|
223
|
+
nock(AUTH_ORIGIN).get('/.well-known/oauth-authorization-server')
|
|
224
|
+
.reply(200, { ...AS_METADATA, authorization_endpoint: 'http://auth.example.com/authorize' });
|
|
225
|
+
|
|
226
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
227
|
+
|
|
228
|
+
expect(error.status).to.equal(400);
|
|
229
|
+
expect(error.message).to.contain('must use https');
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('blocks a metadata URL that points to a private address', async () => {
|
|
233
|
+
unauthorized('Bearer resource_metadata="https://10.0.0.5/.well-known/oauth-protected-resource"');
|
|
234
|
+
|
|
235
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
236
|
+
|
|
237
|
+
expect(error.status).to.equal(400);
|
|
238
|
+
expect(error.message).to.contain('private or reserved address');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('blocks an MCP server URL that is not https', async () => {
|
|
242
|
+
const error = await rejection(discovery.discover('http://mcp.example.com/mcp'));
|
|
243
|
+
|
|
244
|
+
expect(error.status).to.equal(400);
|
|
245
|
+
expect(error.message).to.contain('https is required');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('answers 502 when the MCP server cannot be reached', async () => {
|
|
249
|
+
nock(MCP_ORIGIN).post('/mcp').replyWithError('connect ECONNREFUSED');
|
|
250
|
+
|
|
251
|
+
const error = await rejection(discovery.discover(SERVER_URL));
|
|
252
|
+
|
|
253
|
+
expect(error.status).to.equal(502);
|
|
254
|
+
expect(error.code).to.equal('provider_error');
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('allows a local http server when insecure URLs are allowed', async () => {
|
|
258
|
+
process.env.MCP_OAUTH_ALLOW_INSECURE_URLS = 'true';
|
|
259
|
+
const local = 'http://localhost:3232';
|
|
260
|
+
nock(local).post('/mcp').reply(401, {}, { 'WWW-Authenticate': 'Bearer resource_metadata="' + local + '/.well-known/oauth-protected-resource/mcp"' });
|
|
261
|
+
nock(local)
|
|
262
|
+
.get('/.well-known/oauth-protected-resource/mcp').reply(200, { resource: local + '/mcp', authorization_servers: [local] })
|
|
263
|
+
.get('/.well-known/oauth-authorization-server')
|
|
264
|
+
.reply(200, { issuer: local, authorization_endpoint: local + '/authorize', token_endpoint: local + '/token', registration_endpoint: local + '/register' });
|
|
265
|
+
|
|
266
|
+
const result = await discovery.discover(local + '/mcp');
|
|
267
|
+
|
|
268
|
+
expect(result.authorization_endpoint).to.equal(local + '/authorize');
|
|
269
|
+
expect(result.registration_endpoint).to.equal(local + '/register');
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe('register', () => {
|
|
274
|
+
|
|
275
|
+
it('registers Tiledesk with the redirect URI', async () => {
|
|
276
|
+
nock(AUTH_ORIGIN).post('/register', (body) => {
|
|
277
|
+
expect(body).to.deep.equal({
|
|
278
|
+
client_name: 'Tiledesk',
|
|
279
|
+
redirect_uris: [REDIRECT_URI],
|
|
280
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
281
|
+
response_types: ['code'],
|
|
282
|
+
token_endpoint_auth_method: 'client_secret_post'
|
|
283
|
+
});
|
|
284
|
+
return true;
|
|
285
|
+
}).reply(201, { client_id: 'client-1', client_secret: 'secret-1', token_endpoint_auth_method: 'client_secret_post' });
|
|
286
|
+
|
|
287
|
+
const client = await discovery.register(AS_METADATA, REDIRECT_URI);
|
|
288
|
+
|
|
289
|
+
expect(client).to.deep.equal({ client_id: 'client-1', client_secret: 'secret-1', token_endpoint_auth_method: 'client_secret_post' });
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('asks for client_secret_basic when it is the only method supported', async () => {
|
|
293
|
+
nock(AUTH_ORIGIN).post('/register', (body) => body.token_endpoint_auth_method === 'client_secret_basic')
|
|
294
|
+
.reply(201, { client_id: 'client-2', client_secret: 'secret-2' });
|
|
295
|
+
|
|
296
|
+
const client = await discovery.register(
|
|
297
|
+
{ ...AS_METADATA, token_endpoint_auth_methods_supported: ['client_secret_basic'] },
|
|
298
|
+
REDIRECT_URI
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
expect(client.client_id).to.equal('client-2');
|
|
302
|
+
expect(client.token_endpoint_auth_method).to.equal('client_secret_basic');
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('treats a client without a secret as public', async () => {
|
|
306
|
+
nock(AUTH_ORIGIN).post('/register').reply(201, { client_id: 'public-1' });
|
|
307
|
+
|
|
308
|
+
const client = await discovery.register(AS_METADATA, REDIRECT_URI);
|
|
309
|
+
|
|
310
|
+
expect(client).to.deep.equal({ client_id: 'public-1', token_endpoint_auth_method: 'none' });
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('fails without a registration endpoint', async () => {
|
|
314
|
+
const { registration_endpoint, ...withoutRegistration } = AS_METADATA;
|
|
315
|
+
|
|
316
|
+
const error = await rejection(discovery.register(withoutRegistration, REDIRECT_URI));
|
|
317
|
+
|
|
318
|
+
expect(error.status).to.equal(400);
|
|
319
|
+
expect(error.message).to.equal("This MCP server does not support dynamic client registration; use mode 'manual'");
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('reports a rejected registration as a provider error', async () => {
|
|
323
|
+
nock(AUTH_ORIGIN).post('/register').reply(400, { error: 'invalid_redirect_uri', error_description: 'Redirect URI not allowed' });
|
|
324
|
+
|
|
325
|
+
const error = await rejection(discovery.register(AS_METADATA, REDIRECT_URI));
|
|
326
|
+
|
|
327
|
+
expect(error.status).to.equal(502);
|
|
328
|
+
expect(error.message).to.equal('Dynamic client registration failed: Redirect URI not allowed');
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { expect } = require('chai');
|
|
4
|
+
const { defaultScopesFor } = require('../services/mcpOAuthGoogleScopes');
|
|
5
|
+
|
|
6
|
+
describe('mcpOAuthGoogleScopes', () => {
|
|
7
|
+
|
|
8
|
+
it('returns the scopes of known Google MCP servers', () => {
|
|
9
|
+
expect(defaultScopesFor('https://bigquery.googleapis.com/mcp')).to.deep.equal(['https://www.googleapis.com/auth/bigquery']);
|
|
10
|
+
expect(defaultScopesFor('https://gmailmcp.googleapis.com/mcp/v1')).to.include('https://www.googleapis.com/auth/gmail.readonly');
|
|
11
|
+
expect(defaultScopesFor('https://people.googleapis.com/mcp/v1')).to.include('https://www.googleapis.com/auth/contacts.readonly');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns nothing for unknown hosts, non-MCP paths, http and invalid URLs', () => {
|
|
15
|
+
expect(defaultScopesFor('https://run.googleapis.com/mcp')).to.deep.equal([]);
|
|
16
|
+
expect(defaultScopesFor('https://people.googleapis.com/v1/people/me')).to.deep.equal([]);
|
|
17
|
+
expect(defaultScopesFor('http://calendarmcp.googleapis.com/mcp/v1')).to.deep.equal([]);
|
|
18
|
+
expect(defaultScopesFor('not a url')).to.deep.equal([]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('returns a copy that callers can change', () => {
|
|
22
|
+
defaultScopesFor('https://drivemcp.googleapis.com/mcp/v1').push('x');
|
|
23
|
+
expect(defaultScopesFor('https://drivemcp.googleapis.com/mcp/v1')).to.not.include('x');
|
|
24
|
+
});
|
|
25
|
+
});
|