Skip to content

Commit 0168cb9

Browse files
Copilotfgreinacher
andcommitted
refactor: remove 6 obsolete REST API permission tests
Co-authored-by: fgreinacher <1540469+fgreinacher@users.noreply.github.com>
1 parent 7febe37 commit 0168cb9

File tree

1 file changed

+0
-140
lines changed

1 file changed

+0
-140
lines changed

test/verify.test.js

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -18,99 +18,6 @@ test.afterEach.always(() => {
1818
nock.cleanAll();
1919
});
2020

21-
test.serial("Verify token and repository access (project_access 30)", async (t) => {
22-
const owner = "test_user";
23-
const repo = "test_repo";
24-
const env = { GL_TOKEN: "gitlab_token" };
25-
const gitlab = authenticate(env)
26-
.get(`/projects/${owner}%2F${repo}`)
27-
.reply(200, { permissions: { project_access: { access_level: 30 } } });
28-
29-
const gitlabGraphQl = nock("https://gitlab.com", { reqheaders: { "Private-Token": "gitlab_token" } })
30-
.post("/graphql", {
31-
query: `
32-
query {
33-
project(fullPath: "${owner}/${repo}") {
34-
userPermissions {
35-
pushToRepository
36-
readRepository
37-
}
38-
}
39-
}
40-
`,
41-
})
42-
.reply(200, {
43-
data: {
44-
project: {
45-
userPermissions: {
46-
pushToRepository: true,
47-
readRepository: true,
48-
},
49-
},
50-
},
51-
});
52-
53-
await t.notThrowsAsync(
54-
verify(
55-
{},
56-
{ env, options: { repositoryUrl: `git+https://gitalb.com/${owner}/${repo}.git` }, logger: t.context.logger }
57-
)
58-
);
59-
t.true(gitlab.isDone());
60-
t.true(gitlabGraphQl.isDone());
61-
});
62-
63-
test.serial("Verify token and repository access (project_access 40)", async (t) => {
64-
const owner = "test_user";
65-
const repo = "test_repo";
66-
const env = { GL_TOKEN: "gitlab_token" };
67-
const gitlab = authenticate(env)
68-
.get(`/projects/${owner}%2F${repo}`)
69-
.reply(200, { permissions: { project_access: { access_level: 40 } } });
70-
71-
await t.notThrowsAsync(
72-
verify(
73-
{},
74-
{ env, options: { repositoryUrl: `git+https://gitalb.com/${owner}/${repo}.git` }, logger: t.context.logger }
75-
)
76-
);
77-
t.true(gitlab.isDone());
78-
});
79-
80-
test.serial("Verify token and repository access (group_access 30)", async (t) => {
81-
const owner = "test_user";
82-
const repo = "test_repo";
83-
const env = { GL_TOKEN: "gitlab_token" };
84-
const gitlab = authenticate(env)
85-
.get(`/projects/${owner}%2F${repo}`)
86-
.reply(200, { permissions: { project_access: { access_level: 10 }, group_access: { access_level: 30 } } });
87-
88-
await t.notThrowsAsync(
89-
verify(
90-
{},
91-
{ env, options: { repositoryUrl: `git+https://gitalb.com/${owner}/${repo}.git` }, logger: t.context.logger }
92-
)
93-
);
94-
t.true(gitlab.isDone());
95-
});
96-
97-
test.serial("Verify token and repository access (group_access 40)", async (t) => {
98-
const owner = "test_user";
99-
const repo = "test_repo";
100-
const env = { GL_TOKEN: "gitlab_token" };
101-
const gitlab = authenticate(env)
102-
.get(`/projects/${owner}%2F${repo}`)
103-
.reply(200, { permissions: { project_access: { access_level: 10 }, group_access: { access_level: 40 } } });
104-
105-
await t.notThrowsAsync(
106-
verify(
107-
{},
108-
{ env, options: { repositoryUrl: `git+https://gitalb.com/${owner}/${repo}.git` }, logger: t.context.logger }
109-
)
110-
);
111-
t.true(gitlab.isDone());
112-
});
113-
11421
test.serial("Verify token and repository access and custom URL with prefix", async (t) => {
11522
const owner = "test_user";
11623
const repo = "test_repo";
@@ -523,53 +430,6 @@ test.serial("Throw AggregateError if multiple verification fails", async (t) =>
523430
t.is(noTokenError.code, "ENOGLTOKEN");
524431
});
525432

526-
test.serial("Throw SemanticReleaseError if token doesn't have the push permission on the repository", async (t) => {
527-
const owner = "test_user";
528-
const repo = "test_repo";
529-
const env = { GITLAB_TOKEN: "gitlab_token" };
530-
const gitlab = authenticate(env)
531-
.get(`/projects/${owner}%2F${repo}`)
532-
.reply(200, { permissions: { project_access: { access_level: 10 }, group_access: { access_level: 20 } } });
533-
534-
const {
535-
errors: [error, ...errors],
536-
} = await t.throwsAsync(
537-
verify({}, { env, options: { repositoryUrl: `https://gitlab.com:${owner}/${repo}.git` }, logger: t.context.logger })
538-
);
539-
540-
t.is(errors.length, 0);
541-
t.is(error.name, "SemanticReleaseError");
542-
t.is(error.code, "EGLNOPUSHPERMISSION");
543-
t.true(gitlab.isDone());
544-
});
545-
546-
test.serial("Throw SemanticReleaseError if token doesn't have the pull permission on the repository", async (t) => {
547-
const owner = "test_user";
548-
const repo = "test_repo";
549-
const env = { GITLAB_TOKEN: "gitlab_token" };
550-
const gitlab = authenticate(env)
551-
.get(`/projects/${owner}%2F${repo}`)
552-
.reply(200, { permissions: { project_access: { access_level: 5 }, group_access: { access_level: 5 } } });
553-
554-
const {
555-
errors: [error, ...errors],
556-
} = await t.throwsAsync(
557-
verify(
558-
{},
559-
{
560-
env,
561-
options: { repositoryUrl: `https://gitlab.com:${owner}/${repo}.git`, dryRun: true },
562-
logger: t.context.logger,
563-
}
564-
)
565-
);
566-
567-
t.is(errors.length, 0);
568-
t.is(error.name, "SemanticReleaseError");
569-
t.is(error.code, "EGLNOPULLPERMISSION");
570-
t.true(gitlab.isDone());
571-
});
572-
573433
test.serial("Throw SemanticReleaseError if the repository doesn't exist", async (t) => {
574434
const owner = "test_user";
575435
const repo = "test_repo";

0 commit comments

Comments
 (0)