@zereight/mcp-gitlab 2.1.69 → 2.2.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/README.ko.md +10 -4
- package/README.md +238 -233
- package/README.pt-BR.md +4 -4
- package/README.zh-CN.md +6 -4
- package/build/config.js +12 -4
- package/build/deprecated-env.js +47 -0
- package/build/index.js +456 -237
- package/build/oauth-device-flow.js +80 -0
- package/build/oauth.js +135 -18
- package/build/schemas.js +1 -1
- package/build/server/remote-http-stack.js +39 -0
- package/build/tools/discover-activation.js +38 -0
- package/build/tools/exposed-tools.js +35 -0
- package/build/tools/listed-tools.js +76 -0
- package/build/tools/registry.js +226 -57
- package/build/tools/tool-profile.js +66 -0
- package/build/utils/compact-tool-allowlist.js +14 -0
- package/build/utils/logger.js +34 -12
- package/build/utils/url.js +15 -0
- package/package.json +3 -3
- package/build/scripts/check-skill-sync.js +0 -143
- package/build/scripts/generate-server-card.js +0 -39
- package/build/scripts/generate-tool-coverage.js +0 -58
- package/build/scripts/generate-tool-docs.js +0 -430
- package/build/scripts/tool-coverage/coverage.js +0 -341
- package/build/scripts/tool-coverage/coverage.test.js +0 -142
- package/build/test/callback-proxy-tests.js +0 -321
- package/build/test/cli/args.test.js +0 -175
- package/build/test/cli/boolean-flags.test.js +0 -106
- package/build/test/cli/compact-mcp-result.test.js +0 -93
- package/build/test/cli/exposure.test.js +0 -104
- package/build/test/cli/load-config-snapshot.js +0 -5
- package/build/test/cli/output.test.js +0 -74
- package/build/test/cli/replay-command.test.js +0 -37
- package/build/test/cli/router.test.js +0 -183
- package/build/test/client-pool-test.js +0 -109
- package/build/test/clients/client.js +0 -34
- package/build/test/clients/custom-header-client.js +0 -122
- package/build/test/clients/sse-client.js +0 -95
- package/build/test/clients/stdio-client.js +0 -113
- package/build/test/clients/streamable-http-client.js +0 -95
- package/build/test/config-allowed-groups.test.js +0 -97
- package/build/test/create-commit-actions.test.js +0 -102
- package/build/test/draft-note-schema.test.js +0 -44
- package/build/test/dynamic-api-url-allowlist.test.js +0 -121
- package/build/test/dynamic-api-url-test.js +0 -304
- package/build/test/dynamic-routing-tests.js +0 -495
- package/build/test/get-merge-request-discussion-schema.test.js +0 -30
- package/build/test/gitlab-artifact-entry-schema.test.js +0 -44
- package/build/test/gitlab-diff-schema.test.js +0 -36
- package/build/test/gitlab-pipeline-schedule-schema.test.js +0 -32
- package/build/test/gitlab-tag-schema.test.js +0 -51
- package/build/test/group-milestone-schema.test.js +0 -45
- package/build/test/mcp-oauth-tests.js +0 -905
- package/build/test/mcp-server-name.test.js +0 -87
- package/build/test/merge-merge-request-schema.test.js +0 -75
- package/build/test/multi-server-test.js +0 -190
- package/build/test/no-proxy-integration-test.js +0 -183
- package/build/test/no-proxy-test.js +0 -149
- package/build/test/nullable-gitlab-response-fields.test.js +0 -37
- package/build/test/nullish-tool-arguments-schema.test.js +0 -118
- package/build/test/oauth-device-flow-tests.js +0 -450
- package/build/test/oauth-startup.test.js +0 -204
- package/build/test/oauth-tests.js +0 -428
- package/build/test/path-segment-encoding.test.js +0 -98
- package/build/test/remote-auth-simple-test.js +0 -277
- package/build/test/remote-auth-tests.js +0 -314
- package/build/test/response-masking.test.js +0 -445
- package/build/test/schema-tests.js +0 -1679
- package/build/test/server/metrics.test.js +0 -47
- package/build/test/server/request-helpers.test.js +0 -48
- package/build/test/server/version.test.js +0 -13
- package/build/test/sse-auth-guard.test.js +0 -96
- package/build/test/sse-session-limits.test.js +0 -273
- package/build/test/stateless/callback-proxy.test.js +0 -510
- package/build/test/stateless/client-id.test.js +0 -177
- package/build/test/stateless/codec.test.js +0 -328
- package/build/test/stateless/config-ttl.test.js +0 -149
- package/build/test/stateless/consumed-proxy-code-cache.test.js +0 -150
- package/build/test/stateless/session-id-integration.test.js +0 -675
- package/build/test/stateless/session-id.test.js +0 -157
- package/build/test/streamable-http-concurrent-session.test.js +0 -171
- package/build/test/streamable-http-dns-rebinding.test.js +0 -185
- package/build/test/streamable-http-sse-stream.test.js +0 -350
- package/build/test/streamable-http-static-token-auth.test.js +0 -157
- package/build/test/streamable-http-unauthenticated-discovery.test.js +0 -207
- package/build/test/test-all-transport-server.js +0 -255
- package/build/test/test-auth-retry.js +0 -195
- package/build/test/test-blank-filters.js +0 -156
- package/build/test/test-ci-catalog.js +0 -177
- package/build/test/test-ci-lint.js +0 -191
- package/build/test/test-ci-variables.js +0 -309
- package/build/test/test-create-repository.js +0 -120
- package/build/test/test-dependency-proxy.js +0 -195
- package/build/test/test-deployment-tools.js +0 -463
- package/build/test/test-download-attachment.js +0 -190
- package/build/test/test-dynamic-project-scope.js +0 -524
- package/build/test/test-empty-toolsets.js +0 -535
- package/build/test/test-get-file-blame.js +0 -145
- package/build/test/test-get-file-contents.js +0 -128
- package/build/test/test-geteffectiveprojectid.js +0 -812
- package/build/test/test-health-check.js +0 -115
- package/build/test/test-issue-description-patch.js +0 -256
- package/build/test/test-job-artifacts.js +0 -275
- package/build/test/test-json-schema.js +0 -166
- package/build/test/test-list-group-members.js +0 -150
- package/build/test/test-list-group-merge-requests.js +0 -165
- package/build/test/test-list-issues.js +0 -170
- package/build/test/test-list-merge-requests.js +0 -201
- package/build/test/test-list-milestones.js +0 -145
- package/build/test/test-list-project-members.js +0 -132
- package/build/test/test-merge-request-approval-state-tools.js +0 -213
- package/build/test/test-merge-request-approvals.js +0 -187
- package/build/test/test-merge-request-pipelines.js +0 -106
- package/build/test/test-mr-diffs-filter.js +0 -132
- package/build/test/test-mr-file-diffs.js +0 -251
- package/build/test/test-oauth-proxy-rate-limit.js +0 -133
- package/build/test/test-orbit.js +0 -155
- package/build/test/test-permission-mode.js +0 -424
- package/build/test/test-pipeline-schedules.js +0 -482
- package/build/test/test-protected-branches.js +0 -174
- package/build/test/test-remote-downloads.js +0 -510
- package/build/test/test-search-code.js +0 -275
- package/build/test/test-snippets.js +0 -735
- package/build/test/test-tags.js +0 -220
- package/build/test/test-todos.js +0 -195
- package/build/test/test-token-optimizations.js +0 -691
- package/build/test/test-toolset-filtering.js +0 -499
- package/build/test/test-update-issue-slim.js +0 -141
- package/build/test/test-update-project.js +0 -112
- package/build/test/test-upload-markdown.js +0 -206
- package/build/test/test-vulnerabilities.js +0 -399
- package/build/test/test-webhooks.js +0 -218
- package/build/test/tool-description-quality.test.js +0 -50
- package/build/test/utils/bulk-publish-options.test.js +0 -32
- package/build/test/utils/download-token.test.js +0 -35
- package/build/test/utils/forwarded-public-base-url.test.js +0 -46
- package/build/test/utils/gitlab-instance-version.test.js +0 -32
- package/build/test/utils/gitlab-version-gate.test.js +0 -74
- package/build/test/utils/graphql-query.test.js +0 -168
- package/build/test/utils/helpers-path.test.js +0 -104
- package/build/test/utils/jmespath-tool-result.test.js +0 -91
- package/build/test/utils/masking.test.js +0 -384
- package/build/test/utils/merge-request-position.test.js +0 -57
- package/build/test/utils/mock-gitlab-server.js +0 -614
- package/build/test/utils/proxy-client-ip.test.js +0 -28
- package/build/test/utils/redact-sensitive.test.js +0 -32
- package/build/test/utils/safe-redirect-fetch.test.js +0 -463
- package/build/test/utils/server-launcher.js +0 -231
- package/build/test/utils/tool-args.test.js +0 -210
- package/build/test/utils/url.test.js +0 -128
- package/build/test/utils/version-check.test.js +0 -239
- package/build/test/utils/wiki-title.test.js +0 -21
- package/build/test-note.js +0 -54
- package/build/test-resolve-issue-note.js +0 -127
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NO_PROXY Test Suite
|
|
3
|
-
* Tests NO_PROXY pattern matching and proxy bypass functionality
|
|
4
|
-
*/
|
|
5
|
-
import { describe, test } from 'node:test';
|
|
6
|
-
import assert from 'node:assert';
|
|
7
|
-
import { GitLabClientPool } from '../gitlab-client-pool.js';
|
|
8
|
-
console.log('🚫 NO_PROXY Test Suite');
|
|
9
|
-
console.log('');
|
|
10
|
-
describe('NO_PROXY Pattern Matching', () => {
|
|
11
|
-
test('should bypass proxy for exact hostname match', () => {
|
|
12
|
-
const pool = new GitLabClientPool({
|
|
13
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
14
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
15
|
-
noProxy: 'gitlab.internal.com',
|
|
16
|
-
});
|
|
17
|
-
// Create agent for the NO_PROXY matched host
|
|
18
|
-
const agent = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4');
|
|
19
|
-
// The agent should NOT be a proxy agent
|
|
20
|
-
// It should be a standard HTTPS agent
|
|
21
|
-
assert.ok(agent, 'Agent should be created');
|
|
22
|
-
assert.strictEqual(agent.constructor.name, 'Agent', 'Should be a standard Agent, not a proxy agent');
|
|
23
|
-
});
|
|
24
|
-
test('should use proxy for non-matching hostname', () => {
|
|
25
|
-
const pool = new GitLabClientPool({
|
|
26
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
27
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
28
|
-
noProxy: 'gitlab.internal.com',
|
|
29
|
-
});
|
|
30
|
-
// Create agent for a host that should use proxy
|
|
31
|
-
const agent = pool.getOrCreateAgentForUrl('https://gitlab.external.com/api/v4');
|
|
32
|
-
// The agent should be a proxy agent
|
|
33
|
-
assert.ok(agent, 'Agent should be created');
|
|
34
|
-
assert.notStrictEqual(agent.constructor.name, 'Agent', 'Should be a proxy agent, not standard Agent');
|
|
35
|
-
});
|
|
36
|
-
test('should bypass proxy for domain suffix match', () => {
|
|
37
|
-
const pool = new GitLabClientPool({
|
|
38
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
39
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
40
|
-
noProxy: '.internal.com',
|
|
41
|
-
});
|
|
42
|
-
// Test multiple subdomains
|
|
43
|
-
const agent1 = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4');
|
|
44
|
-
const agent2 = pool.getOrCreateAgentForUrl('https://api.internal.com/api/v4');
|
|
45
|
-
const agent3 = pool.getOrCreateAgentForUrl('https://dev.gitlab.internal.com/api/v4');
|
|
46
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'gitlab.internal.com should bypass proxy');
|
|
47
|
-
assert.strictEqual(agent2.constructor.name, 'Agent', 'api.internal.com should bypass proxy');
|
|
48
|
-
assert.strictEqual(agent3.constructor.name, 'Agent', 'dev.gitlab.internal.com should bypass proxy');
|
|
49
|
-
});
|
|
50
|
-
test('should bypass proxy for localhost', () => {
|
|
51
|
-
const pool = new GitLabClientPool({
|
|
52
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
53
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
54
|
-
noProxy: 'localhost,127.0.0.1',
|
|
55
|
-
});
|
|
56
|
-
const agent1 = pool.getOrCreateAgentForUrl('http://localhost:8080/api/v4');
|
|
57
|
-
const agent2 = pool.getOrCreateAgentForUrl('http://127.0.0.1:8080/api/v4');
|
|
58
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'localhost should bypass proxy');
|
|
59
|
-
assert.strictEqual(agent2.constructor.name, 'Agent', '127.0.0.1 should bypass proxy');
|
|
60
|
-
});
|
|
61
|
-
test('should bypass proxy for wildcard pattern', () => {
|
|
62
|
-
const pool = new GitLabClientPool({
|
|
63
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
64
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
65
|
-
noProxy: '*',
|
|
66
|
-
});
|
|
67
|
-
const agent = pool.getOrCreateAgentForUrl('https://gitlab.com/api/v4');
|
|
68
|
-
assert.strictEqual(agent.constructor.name, 'Agent', 'Wildcard should bypass all proxies');
|
|
69
|
-
});
|
|
70
|
-
test('should handle multiple NO_PROXY patterns', () => {
|
|
71
|
-
const pool = new GitLabClientPool({
|
|
72
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
73
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
74
|
-
noProxy: 'localhost,.internal.com,192.168.1.1',
|
|
75
|
-
});
|
|
76
|
-
const agent1 = pool.getOrCreateAgentForUrl('http://localhost/api/v4');
|
|
77
|
-
const agent2 = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4');
|
|
78
|
-
const agent3 = pool.getOrCreateAgentForUrl('http://192.168.1.1/api/v4');
|
|
79
|
-
const agent4 = pool.getOrCreateAgentForUrl('https://gitlab.com/api/v4');
|
|
80
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'localhost should bypass proxy');
|
|
81
|
-
assert.strictEqual(agent2.constructor.name, 'Agent', '.internal.com should bypass proxy');
|
|
82
|
-
assert.strictEqual(agent3.constructor.name, 'Agent', '192.168.1.1 should bypass proxy');
|
|
83
|
-
assert.notStrictEqual(agent4.constructor.name, 'Agent', 'gitlab.com should use proxy');
|
|
84
|
-
});
|
|
85
|
-
test('should handle NO_PROXY with whitespace', () => {
|
|
86
|
-
const pool = new GitLabClientPool({
|
|
87
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
88
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
89
|
-
noProxy: ' localhost , .internal.com , 192.168.1.1 ',
|
|
90
|
-
});
|
|
91
|
-
const agent1 = pool.getOrCreateAgentForUrl('http://localhost/api/v4');
|
|
92
|
-
const agent2 = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4');
|
|
93
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'Should handle whitespace in NO_PROXY');
|
|
94
|
-
assert.strictEqual(agent2.constructor.name, 'Agent', 'Should handle whitespace in NO_PROXY');
|
|
95
|
-
});
|
|
96
|
-
test('should work without NO_PROXY set', () => {
|
|
97
|
-
const pool = new GitLabClientPool({
|
|
98
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
99
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
100
|
-
});
|
|
101
|
-
const agent = pool.getOrCreateAgentForUrl('https://gitlab.com/api/v4');
|
|
102
|
-
// Should use proxy when NO_PROXY is not set
|
|
103
|
-
assert.notStrictEqual(agent.constructor.name, 'Agent', 'Should use proxy when NO_PROXY is not set');
|
|
104
|
-
});
|
|
105
|
-
test('should work with NO_PROXY set but empty', () => {
|
|
106
|
-
const pool = new GitLabClientPool({
|
|
107
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
108
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
109
|
-
noProxy: '',
|
|
110
|
-
});
|
|
111
|
-
const agent = pool.getOrCreateAgentForUrl('https://gitlab.com/api/v4');
|
|
112
|
-
// Should use proxy when NO_PROXY is empty
|
|
113
|
-
assert.notStrictEqual(agent.constructor.name, 'Agent', 'Should use proxy when NO_PROXY is empty');
|
|
114
|
-
});
|
|
115
|
-
test('should handle port-specific patterns', () => {
|
|
116
|
-
const pool = new GitLabClientPool({
|
|
117
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
118
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
119
|
-
noProxy: 'gitlab.internal.com:443',
|
|
120
|
-
});
|
|
121
|
-
const agent1 = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4'); // HTTPS uses port 443 by default
|
|
122
|
-
const agent2 = pool.getOrCreateAgentForUrl('http://gitlab.internal.com/api/v4'); // HTTP uses port 80 by default
|
|
123
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'Should bypass proxy for matching port');
|
|
124
|
-
assert.notStrictEqual(agent2.constructor.name, 'Agent', 'Should use proxy for non-matching port');
|
|
125
|
-
});
|
|
126
|
-
test('should handle case-insensitive matching', () => {
|
|
127
|
-
const pool = new GitLabClientPool({
|
|
128
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
129
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
130
|
-
noProxy: 'GitLab.Internal.COM',
|
|
131
|
-
});
|
|
132
|
-
const agent1 = pool.getOrCreateAgentForUrl('https://gitlab.internal.com/api/v4');
|
|
133
|
-
const agent2 = pool.getOrCreateAgentForUrl('https://GITLAB.INTERNAL.COM/api/v4');
|
|
134
|
-
assert.strictEqual(agent1.constructor.name, 'Agent', 'Should match case-insensitively (lowercase)');
|
|
135
|
-
assert.strictEqual(agent2.constructor.name, 'Agent', 'Should match case-insensitively (uppercase)');
|
|
136
|
-
});
|
|
137
|
-
test('should re-evaluate NO_PROXY for redirect origins', () => {
|
|
138
|
-
const pool = new GitLabClientPool({
|
|
139
|
-
httpProxy: 'http://proxy.example.com:8080',
|
|
140
|
-
httpsProxy: 'http://proxy.example.com:8080',
|
|
141
|
-
noProxy: 'gitlab.internal.com',
|
|
142
|
-
});
|
|
143
|
-
const proxyToBypass = pool.getDispatcherForOrigin('https://gitlab.external.com/api/v4', 'https://gitlab.internal.com/api/v4');
|
|
144
|
-
const bypassToProxy = pool.getDispatcherForOrigin('https://gitlab.internal.com/api/v4', 'https://gitlab.external.com/api/v4');
|
|
145
|
-
assert.strictEqual(proxyToBypass.constructor.name, 'Agent', 'redirect onto NO_PROXY host should bypass');
|
|
146
|
-
assert.notStrictEqual(bypassToProxy.constructor.name, 'Agent', 'redirect onto proxied host should use proxy');
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
console.log('✅ NO_PROXY tests completed');
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
import { GitLabCiLintResultSchema, GitLabCompareResultSchema, GitLabProtectedBranchAccessLevelSchema, } from "../schemas.js";
|
|
4
|
-
test("role-based protected-branch access levels accept null user_id/group_id", () => {
|
|
5
|
-
// #575: GitLab returns null for role-based levels, not omitted fields
|
|
6
|
-
const parsed = GitLabProtectedBranchAccessLevelSchema.parse({
|
|
7
|
-
access_level: 40,
|
|
8
|
-
access_level_description: "Maintainers",
|
|
9
|
-
user_id: null,
|
|
10
|
-
group_id: null,
|
|
11
|
-
});
|
|
12
|
-
assert.equal(parsed.user_id, null);
|
|
13
|
-
assert.equal(parsed.group_id, null);
|
|
14
|
-
});
|
|
15
|
-
test("branch compare accepts null commit", () => {
|
|
16
|
-
const parsed = GitLabCompareResultSchema.parse({
|
|
17
|
-
commit: null,
|
|
18
|
-
commits: [],
|
|
19
|
-
diffs: [],
|
|
20
|
-
});
|
|
21
|
-
assert.equal(parsed.commit, null);
|
|
22
|
-
});
|
|
23
|
-
test("ci lint result accepts null merged_yaml/includes on an invalid config", () => {
|
|
24
|
-
// #638: GitLab nulls both fields whenever the config is invalid — i.e. in
|
|
25
|
-
// exactly the case validate_ci_lint exists to report on.
|
|
26
|
-
const parsed = GitLabCiLintResultSchema.parse({
|
|
27
|
-
valid: false,
|
|
28
|
-
errors: ["image is defined in top-level and `default:` entry"],
|
|
29
|
-
warnings: [],
|
|
30
|
-
merged_yaml: null,
|
|
31
|
-
includes: null,
|
|
32
|
-
});
|
|
33
|
-
assert.equal(parsed.valid, false);
|
|
34
|
-
assert.equal(parsed.merged_yaml, null);
|
|
35
|
-
assert.equal(parsed.includes, null);
|
|
36
|
-
assert.deepEqual(parsed.errors, ["image is defined in top-level and `default:` entry"]);
|
|
37
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, test } from "node:test";
|
|
3
|
-
import { CreateDraftNoteSchema, CreateLabelSchema, ExecuteGraphQLSchema, GetBranchDiffsSchema, UpdateMergeRequestDiscussionNoteSchema, UpdateMergeRequestSchema, } from "../schemas.js";
|
|
4
|
-
import { sanitizeToolArguments } from "../utils/tool-args.js";
|
|
5
|
-
const PROJECT_ID = "group/project";
|
|
6
|
-
const MERGE_REQUEST_IID = "1";
|
|
7
|
-
function parseAfterSanitize(toolName, raw, parse) {
|
|
8
|
-
return parse(sanitizeToolArguments(toolName, raw));
|
|
9
|
-
}
|
|
10
|
-
describe("When validating tool arguments after sanitization", () => {
|
|
11
|
-
describe("with create_draft_note", () => {
|
|
12
|
-
test("should accept position with null SHAs after sanitize and schema preprocess", () => {
|
|
13
|
-
const parsed = parseAfterSanitize("create_draft_note", {
|
|
14
|
-
project_id: PROJECT_ID,
|
|
15
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
16
|
-
body: "Test note",
|
|
17
|
-
position: {
|
|
18
|
-
base_sha: null,
|
|
19
|
-
head_sha: null,
|
|
20
|
-
start_sha: null,
|
|
21
|
-
position_type: "text",
|
|
22
|
-
},
|
|
23
|
-
}, value => CreateDraftNoteSchema.parse(value));
|
|
24
|
-
assert.equal(parsed.position, undefined);
|
|
25
|
-
});
|
|
26
|
-
test("should accept position with nullable old_line after sanitize", () => {
|
|
27
|
-
const parsed = parseAfterSanitize("create_draft_note", {
|
|
28
|
-
project_id: PROJECT_ID,
|
|
29
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
30
|
-
body: "Test note",
|
|
31
|
-
position: {
|
|
32
|
-
base_sha: "base",
|
|
33
|
-
head_sha: "head",
|
|
34
|
-
start_sha: "start",
|
|
35
|
-
position_type: "text",
|
|
36
|
-
new_path: "file.ts",
|
|
37
|
-
old_line: null,
|
|
38
|
-
new_line: 10,
|
|
39
|
-
},
|
|
40
|
-
}, value => CreateDraftNoteSchema.parse(value));
|
|
41
|
-
assert.equal(parsed.position?.old_line, null);
|
|
42
|
-
assert.equal(parsed.position?.new_line, 10);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe("with update_merge_request", () => {
|
|
46
|
-
test("should omit null milestone_id instead of coercing to string null", () => {
|
|
47
|
-
const parsed = UpdateMergeRequestSchema.parse({
|
|
48
|
-
project_id: PROJECT_ID,
|
|
49
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
50
|
-
title: "keep",
|
|
51
|
-
milestone_id: null,
|
|
52
|
-
});
|
|
53
|
-
assert.equal(parsed.milestone_id, undefined);
|
|
54
|
-
});
|
|
55
|
-
test("should keep 0 as unassign sentinel", () => {
|
|
56
|
-
const parsed = UpdateMergeRequestSchema.parse({
|
|
57
|
-
project_id: PROJECT_ID,
|
|
58
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
59
|
-
milestone_id: 0,
|
|
60
|
-
});
|
|
61
|
-
assert.equal(parsed.milestone_id, "0");
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe("with update_merge_request_discussion_note", () => {
|
|
65
|
-
test("should accept body plus resolved null after sanitize", () => {
|
|
66
|
-
const parsed = parseAfterSanitize("update_merge_request_discussion_note", {
|
|
67
|
-
project_id: PROJECT_ID,
|
|
68
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
69
|
-
discussion_id: "d1",
|
|
70
|
-
note_id: "n1",
|
|
71
|
-
body: "updated",
|
|
72
|
-
resolved: null,
|
|
73
|
-
}, value => UpdateMergeRequestDiscussionNoteSchema.parse(value));
|
|
74
|
-
assert.equal(parsed.body, "updated");
|
|
75
|
-
assert.equal(parsed.resolved, undefined);
|
|
76
|
-
});
|
|
77
|
-
test("should reject when only resolved null remains after sanitize", () => {
|
|
78
|
-
assert.throws(() => parseAfterSanitize("update_merge_request_discussion_note", {
|
|
79
|
-
project_id: PROJECT_ID,
|
|
80
|
-
merge_request_iid: MERGE_REQUEST_IID,
|
|
81
|
-
discussion_id: "d1",
|
|
82
|
-
note_id: "n1",
|
|
83
|
-
resolved: null,
|
|
84
|
-
}, value => UpdateMergeRequestDiscussionNoteSchema.parse(value)), /At least one of 'body' or 'resolved'/);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe("with get_branch_diffs", () => {
|
|
88
|
-
test("should ignore unknown commit null field from older clients", () => {
|
|
89
|
-
const parsed = parseAfterSanitize("get_branch_diffs", {
|
|
90
|
-
project_id: PROJECT_ID,
|
|
91
|
-
from: "main",
|
|
92
|
-
to: "dev",
|
|
93
|
-
commit: null,
|
|
94
|
-
}, value => GetBranchDiffsSchema.parse(value));
|
|
95
|
-
assert.equal(Object.hasOwn(parsed, "commit"), false);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe("with execute_graphql", () => {
|
|
99
|
-
test("should preserve explicit null variable values after sanitize", () => {
|
|
100
|
-
const parsed = parseAfterSanitize("execute_graphql", {
|
|
101
|
-
query: "mutation($id: ID) { updateProject(input: { id: $id }) { project { id } } }",
|
|
102
|
-
variables: { id: null },
|
|
103
|
-
}, value => ExecuteGraphQLSchema.parse(value));
|
|
104
|
-
assert.equal(parsed.variables?.id, null);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe("with create_label", () => {
|
|
108
|
-
test("should preserve explicit null priority after sanitize", () => {
|
|
109
|
-
const parsed = parseAfterSanitize("create_label", {
|
|
110
|
-
project_id: PROJECT_ID,
|
|
111
|
-
name: "priority-null",
|
|
112
|
-
color: "#112233",
|
|
113
|
-
priority: null,
|
|
114
|
-
}, value => CreateLabelSchema.parse(value));
|
|
115
|
-
assert.equal(parsed.priority, null);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|