gitlab-akerl 4.0.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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.prospectus +11 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +229 -0
- data/CONTRIBUTING.md +195 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +192 -0
- data/Rakefile +9 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/exe/gitlab +7 -0
- data/gitlab-akerl.gemspec +31 -0
- data/lib/gitlab.rb +45 -0
- data/lib/gitlab/api.rb +19 -0
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +241 -0
- data/lib/gitlab/client.rb +48 -0
- data/lib/gitlab/client/branches.rb +91 -0
- data/lib/gitlab/client/build_triggers.rb +51 -0
- data/lib/gitlab/client/build_variables.rb +66 -0
- data/lib/gitlab/client/builds.rb +106 -0
- data/lib/gitlab/client/commits.rb +121 -0
- data/lib/gitlab/client/groups.rb +144 -0
- data/lib/gitlab/client/issues.rb +113 -0
- data/lib/gitlab/client/labels.rb +57 -0
- data/lib/gitlab/client/merge_requests.rb +168 -0
- data/lib/gitlab/client/milestones.rb +78 -0
- data/lib/gitlab/client/namespaces.rb +20 -0
- data/lib/gitlab/client/notes.rb +161 -0
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +471 -0
- data/lib/gitlab/client/repositories.rb +78 -0
- data/lib/gitlab/client/repository_files.rb +88 -0
- data/lib/gitlab/client/runners.rb +115 -0
- data/lib/gitlab/client/services.rb +50 -0
- data/lib/gitlab/client/snippets.rb +91 -0
- data/lib/gitlab/client/system_hooks.rb +59 -0
- data/lib/gitlab/client/tags.rb +96 -0
- data/lib/gitlab/client/users.rb +250 -0
- data/lib/gitlab/configuration.rb +55 -0
- data/lib/gitlab/error.rb +85 -0
- data/lib/gitlab/file_response.rb +46 -0
- data/lib/gitlab/help.rb +95 -0
- data/lib/gitlab/objectified_hash.rb +34 -0
- data/lib/gitlab/page_links.rb +33 -0
- data/lib/gitlab/paginated_response.rb +97 -0
- data/lib/gitlab/request.rb +117 -0
- data/lib/gitlab/shell.rb +84 -0
- data/lib/gitlab/shell_history.rb +59 -0
- data/lib/gitlab/version.rb +3 -0
- data/spec/fixtures/branch.json +1 -0
- data/spec/fixtures/branch_delete.json +3 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/build.json +38 -0
- data/spec/fixtures/build_artifacts.json +0 -0
- data/spec/fixtures/build_cancel.json +24 -0
- data/spec/fixtures/build_erase.json +24 -0
- data/spec/fixtures/build_retry.json +24 -0
- data/spec/fixtures/builds.json +78 -0
- data/spec/fixtures/builds_commits.json +64 -0
- data/spec/fixtures/compare_merge_request_diff.json +31 -0
- data/spec/fixtures/error_already_exists.json +1 -0
- data/spec/fixtures/error_project_not_found.json +1 -0
- data/spec/fixtures/get_repository_file.json +1 -0
- data/spec/fixtures/git_hook.json +1 -0
- data/spec/fixtures/group.json +60 -0
- data/spec/fixtures/group_create.json +1 -0
- data/spec/fixtures/group_create_with_description.json +1 -0
- data/spec/fixtures/group_delete.json +1 -0
- data/spec/fixtures/group_member.json +1 -0
- data/spec/fixtures/group_member_delete.json +1 -0
- data/spec/fixtures/group_member_edit.json +1 -0
- data/spec/fixtures/group_members.json +1 -0
- data/spec/fixtures/group_projects.json +44 -0
- data/spec/fixtures/group_search.json +2 -0
- data/spec/fixtures/groups.json +2 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/key.json +1 -0
- data/spec/fixtures/keys.json +1 -0
- data/spec/fixtures/label.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/merge_request.json +1 -0
- data/spec/fixtures/merge_request_changes.json +1 -0
- data/spec/fixtures/merge_request_comment.json +1 -0
- data/spec/fixtures/merge_request_comments.json +1 -0
- data/spec/fixtures/merge_request_commits.json +1 -0
- data/spec/fixtures/merge_requests.json +1 -0
- data/spec/fixtures/milestone.json +1 -0
- data/spec/fixtures/milestone_issues.json +1 -0
- data/spec/fixtures/milestones.json +1 -0
- data/spec/fixtures/namespaces.json +1 -0
- data/spec/fixtures/note.json +1 -0
- data/spec/fixtures/notes.json +1 -0
- data/spec/fixtures/pipeline.json +23 -0
- data/spec/fixtures/pipeline_cancel.json +23 -0
- data/spec/fixtures/pipeline_create.json +23 -0
- data/spec/fixtures/pipeline_retry.json +23 -0
- data/spec/fixtures/pipelines.json +48 -0
- data/spec/fixtures/project.json +1 -0
- data/spec/fixtures/project_commit.json +13 -0
- data/spec/fixtures/project_commit_comment.json +1 -0
- data/spec/fixtures/project_commit_comments.json +1 -0
- data/spec/fixtures/project_commit_diff.json +10 -0
- data/spec/fixtures/project_commit_status.json +42 -0
- data/spec/fixtures/project_commits.json +1 -0
- data/spec/fixtures/project_edit.json +21 -0
- data/spec/fixtures/project_events.json +1 -0
- data/spec/fixtures/project_for_user.json +1 -0
- data/spec/fixtures/project_fork.json +50 -0
- data/spec/fixtures/project_fork_link.json +1 -0
- data/spec/fixtures/project_forked_for_user.json +50 -0
- data/spec/fixtures/project_hook.json +1 -0
- data/spec/fixtures/project_hooks.json +1 -0
- data/spec/fixtures/project_issues.json +1 -0
- data/spec/fixtures/project_key.json +6 -0
- data/spec/fixtures/project_keys.json +6 -0
- data/spec/fixtures/project_runner_enable.json +7 -0
- data/spec/fixtures/project_runners.json +16 -0
- data/spec/fixtures/project_search.json +1 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_tag_annotated.json +1 -0
- data/spec/fixtures/project_tag_lightweight.json +1 -0
- data/spec/fixtures/project_tags.json +1 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/project_update_commit_status.json +20 -0
- data/spec/fixtures/projects.json +1 -0
- data/spec/fixtures/raw_file.json +2 -0
- data/spec/fixtures/release_create.json +1 -0
- data/spec/fixtures/release_update.json +1 -0
- data/spec/fixtures/repository_file.json +1 -0
- data/spec/fixtures/runner.json +26 -0
- data/spec/fixtures/runner_delete.json +7 -0
- data/spec/fixtures/runner_edit.json +26 -0
- data/spec/fixtures/runners.json +16 -0
- data/spec/fixtures/runners_all.json +30 -0
- data/spec/fixtures/service.json +1 -0
- data/spec/fixtures/session.json +1 -0
- data/spec/fixtures/shell_history.json +2 -0
- data/spec/fixtures/snippet.json +1 -0
- data/spec/fixtures/snippet_content.json +3 -0
- data/spec/fixtures/snippets.json +1 -0
- data/spec/fixtures/system_hook.json +1 -0
- data/spec/fixtures/system_hooks.json +1 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/tag_create.json +1 -0
- data/spec/fixtures/tag_create_with_description.json +1 -0
- data/spec/fixtures/tag_delete.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team_member.json +1 -0
- data/spec/fixtures/team_members.json +1 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/trigger.json +7 -0
- data/spec/fixtures/triggers.json +16 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/user_block_unblock.json +1 -0
- data/spec/fixtures/user_email.json +1 -0
- data/spec/fixtures/user_emails.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/variable.json +4 -0
- data/spec/fixtures/variables.json +10 -0
- data/spec/gitlab/cli_helpers_spec.rb +57 -0
- data/spec/gitlab/cli_spec.rb +110 -0
- data/spec/gitlab/client/branches_spec.rb +99 -0
- data/spec/gitlab/client/build_triggers_spec.rb +67 -0
- data/spec/gitlab/client/build_variables_spec.rb +86 -0
- data/spec/gitlab/client/builds_spec.rb +148 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +137 -0
- data/spec/gitlab/client/groups_spec.rb +197 -0
- data/spec/gitlab/client/issues_spec.rb +138 -0
- data/spec/gitlab/client/labels_spec.rb +68 -0
- data/spec/gitlab/client/merge_requests_spec.rb +177 -0
- data/spec/gitlab/client/milestones_spec.rb +82 -0
- data/spec/gitlab/client/namespaces_spec.rb +22 -0
- data/spec/gitlab/client/notes_spec.rb +205 -0
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +603 -0
- data/spec/gitlab/client/repositories_spec.rb +109 -0
- data/spec/gitlab/client/repository_files_spec.rb +62 -0
- data/spec/gitlab/client/runners_spec.rb +185 -0
- data/spec/gitlab/client/services_spec.rb +55 -0
- data/spec/gitlab/client/snippets_spec.rb +100 -0
- data/spec/gitlab/client/system_hooks_spec.rb +69 -0
- data/spec/gitlab/client/tags_spec.rb +109 -0
- data/spec/gitlab/client/users_spec.rb +418 -0
- data/spec/gitlab/error_spec.rb +45 -0
- data/spec/gitlab/file_response_spec.rb +33 -0
- data/spec/gitlab/help_spec.rb +46 -0
- data/spec/gitlab/objectified_hash_spec.rb +48 -0
- data/spec/gitlab/page_links_spec.rb +16 -0
- data/spec/gitlab/paginated_response_spec.rb +60 -0
- data/spec/gitlab/request_spec.rb +73 -0
- data/spec/gitlab/shell_history_spec.rb +53 -0
- data/spec/gitlab/shell_spec.rb +80 -0
- data/spec/gitlab_spec.rb +97 -0
- data/spec/spec_helper.rb +74 -0
- metadata +476 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
it { should respond_to :system_hooks }
|
|
5
|
+
it { should respond_to :add_system_hook }
|
|
6
|
+
it { should respond_to :system_hook }
|
|
7
|
+
it { should respond_to :delete_system_hook }
|
|
8
|
+
|
|
9
|
+
describe ".hooks" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("/hooks", "system_hooks")
|
|
12
|
+
@hooks = Gitlab.hooks
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should get the correct resource" do
|
|
16
|
+
expect(a_get("/hooks")).to have_been_made
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should return a paginated response of system hooks" do
|
|
20
|
+
expect(@hooks).to be_a Gitlab::PaginatedResponse
|
|
21
|
+
expect(@hooks.first.url).to eq("http://example.com/hook")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe ".add_hook" do
|
|
26
|
+
before do
|
|
27
|
+
stub_post("/hooks", "system_hook")
|
|
28
|
+
@hook = Gitlab.add_hook("http://example.com/hook")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should get the correct resource" do
|
|
32
|
+
expect(a_post("/hooks")).to have_been_made
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should return information about a added system hook" do
|
|
36
|
+
expect(@hook.url).to eq("http://example.com/hook")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe ".hook" do
|
|
41
|
+
before do
|
|
42
|
+
stub_get("/hooks/3", "system_hook")
|
|
43
|
+
@hook = Gitlab.hook(3)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should get the correct resource" do
|
|
47
|
+
expect(a_get("/hooks/3")).to have_been_made
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return information about a added system hook" do
|
|
51
|
+
expect(@hook.url).to eq("http://example.com/hook")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe ".delete_hook" do
|
|
56
|
+
before do
|
|
57
|
+
stub_delete("/hooks/3", "system_hook")
|
|
58
|
+
@hook = Gitlab.delete_hook(3)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should get the correct resource" do
|
|
62
|
+
expect(a_delete("/hooks/3")).to have_been_made
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should return information about a deleted system hook" do
|
|
66
|
+
expect(@hook.url).to eq("http://example.com/hook")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
it { should respond_to :repo_tags }
|
|
5
|
+
it { should respond_to :repo_tag }
|
|
6
|
+
it { should respond_to :repo_create_tag }
|
|
7
|
+
it { should respond_to :repo_delete_tag }
|
|
8
|
+
it { should respond_to :repo_create_release }
|
|
9
|
+
it { should respond_to :repo_update_release }
|
|
10
|
+
|
|
11
|
+
describe '.tags' do
|
|
12
|
+
before do
|
|
13
|
+
stub_get("/projects/3/repository/tags", "tags")
|
|
14
|
+
@tags = Gitlab.tags(3)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should get the correct resource" do
|
|
18
|
+
expect(a_get("/projects/3/repository/tags")).to have_been_made
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should return a paginated response of repository tags" do
|
|
22
|
+
expect(@tags).to be_a Gitlab::PaginatedResponse
|
|
23
|
+
expect(@tags.map(&:name)).to eq(%w[0.0.2 0.0.1])
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe ".tag" do
|
|
28
|
+
before do
|
|
29
|
+
stub_get("/projects/3/repository/tags/0.0.1", "tag")
|
|
30
|
+
@tag = Gitlab.tag(3, "0.0.1")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get the correct resource" do
|
|
34
|
+
expect(a_get("/projects/3/repository/tags/0.0.1")).to have_been_made
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should return information about a repository tag" do
|
|
38
|
+
expect(@tag.name).to eq("0.0.1")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe ".create_tag" do
|
|
43
|
+
before do
|
|
44
|
+
stub_post("/projects/3/repository/tags", "tag_create")
|
|
45
|
+
@tag = Gitlab.create_tag(3, "0.0.1", "master", 'this tag is annotated', 'and it has release notes')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should get the correct resource" do
|
|
49
|
+
expect(a_post("/projects/3/repository/tags")).to have_been_made
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should return information about a new repository tag" do
|
|
53
|
+
expect(@tag.name).to eq("0.0.1")
|
|
54
|
+
expect(@tag.message).to eq('this tag is annotated')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should return detailed information" do
|
|
58
|
+
expect(@tag.release.description).to eq('and it has release notes')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe ".delete_tag" do
|
|
63
|
+
before do
|
|
64
|
+
stub_delete("/projects/3/repository/tags/0.0.1", "tag_delete")
|
|
65
|
+
@tag = Gitlab.delete_tag(3, "0.0.1")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should get the correct resource" do
|
|
69
|
+
expect(a_delete("/projects/3/repository/tags/0.0.1")).to have_been_made
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return information about the deleted repository tag" do
|
|
73
|
+
expect(@tag.tag_name).to eq("0.0.1")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe ".create_release" do
|
|
78
|
+
before do
|
|
79
|
+
stub_post("/projects/3/repository/tags/0.0.1/release", "release_create")
|
|
80
|
+
@tag = Gitlab.create_release(3, "0.0.1", "Amazing release. Wow")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should get the correct resource" do
|
|
84
|
+
expect(a_post("/projects/3/repository/tags/0.0.1/release")).to have_been_made
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should return information about the tag and the release" do
|
|
88
|
+
expect(@tag.tag_name).to eq("0.0.1")
|
|
89
|
+
expect(@tag.description).to eq("Amazing release. Wow")
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe ".update_release" do
|
|
94
|
+
before do
|
|
95
|
+
stub_put("/projects/3/repository/tags/0.0.1/release", "release_update")
|
|
96
|
+
@tag = Gitlab.update_release(3, "0.0.1", 'Amazing release. Wow')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should update the correct resource" do
|
|
100
|
+
expect(a_put("/projects/3/repository/tags/0.0.1/release")).to have_been_made
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should return information about the tag" do
|
|
104
|
+
expect(@tag.tag_name).to eq("0.0.1")
|
|
105
|
+
expect(@tag.description).to eq('Amazing release. Wow')
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Gitlab::Client do
|
|
4
|
+
describe ".users" do
|
|
5
|
+
before do
|
|
6
|
+
stub_get("/users", "users")
|
|
7
|
+
@users = Gitlab.users
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should get the correct resource" do
|
|
11
|
+
expect(a_get("/users")).to have_been_made
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should return a paginated response of users" do
|
|
15
|
+
expect(@users).to be_a Gitlab::PaginatedResponse
|
|
16
|
+
expect(@users.first.email).to eq("john@example.com")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe ".user" do
|
|
21
|
+
context "with user ID passed" do
|
|
22
|
+
before do
|
|
23
|
+
stub_get("/users/1", "user")
|
|
24
|
+
@user = Gitlab.user(1)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should get the correct resource" do
|
|
28
|
+
expect(a_get("/users/1")).to have_been_made
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return information about a user" do
|
|
32
|
+
expect(@user.email).to eq("john@example.com")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "without user ID passed" do
|
|
37
|
+
before do
|
|
38
|
+
stub_get("/user", "user")
|
|
39
|
+
@user = Gitlab.user
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should get the correct resource" do
|
|
43
|
+
expect(a_get("/user")).to have_been_made
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should return information about an authorized user" do
|
|
47
|
+
expect(@user.email).to eq("john@example.com")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe ".create_user" do
|
|
53
|
+
context "when successful request" do
|
|
54
|
+
before do
|
|
55
|
+
stub_post("/users", "user")
|
|
56
|
+
@user = Gitlab.create_user("email", "pass")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should get the correct resource" do
|
|
60
|
+
body = { email: "email", password: "pass", name: "email" }
|
|
61
|
+
expect(a_post("/users").with(body: body)).to have_been_made
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should return information about a created user" do
|
|
65
|
+
expect(@user.email).to eq("john@example.com")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context "when bad request" do
|
|
70
|
+
it "should throw an exception" do
|
|
71
|
+
stub_post("/users", "error_already_exists", 409)
|
|
72
|
+
expect do
|
|
73
|
+
Gitlab.create_user("email", "pass")
|
|
74
|
+
end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe ".create_user_with_userame" do
|
|
80
|
+
context "when successful request" do
|
|
81
|
+
before do
|
|
82
|
+
stub_post("/users", "user")
|
|
83
|
+
@user = Gitlab.create_user("email", "pass", "username")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should get the correct resource" do
|
|
87
|
+
body = { email: "email", password: "pass", username: "username" }
|
|
88
|
+
expect(a_post("/users").with(body: body)).to have_been_made
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should return information about a created user" do
|
|
92
|
+
expect(@user.email).to eq("john@example.com")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context "when bad request" do
|
|
97
|
+
it "should throw an exception" do
|
|
98
|
+
stub_post("/users", "error_already_exists", 409)
|
|
99
|
+
expect do
|
|
100
|
+
Gitlab.create_user("email", "pass", "username")
|
|
101
|
+
end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe ".edit_user" do
|
|
107
|
+
before do
|
|
108
|
+
@options = { name: "Roberto" }
|
|
109
|
+
stub_put("/users/1", "user").with(body: @options)
|
|
110
|
+
@user = Gitlab.edit_user(1, @options)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "should get the correct resource" do
|
|
114
|
+
expect(a_put("/users/1").with(body: @options)).to have_been_made
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe ".delete_user" do
|
|
119
|
+
before do
|
|
120
|
+
stub_delete("/users/1", "user")
|
|
121
|
+
@user = Gitlab.delete_user(1)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should get the correct resource" do
|
|
125
|
+
expect(a_delete("/users/1")).to have_been_made
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "should return information about a deleted user" do
|
|
129
|
+
expect(@user.email).to eq("john@example.com")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe ".block_user" do
|
|
134
|
+
before do
|
|
135
|
+
stub_put("/users/1/block", "user_block_unblock")
|
|
136
|
+
@result = Gitlab.block_user(1)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "should get the correct resource" do
|
|
140
|
+
expect(a_put("/users/1/block")).to have_been_made
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "should return boolean" do
|
|
144
|
+
expect(@result).to eq(true)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
describe ".unblock_user" do
|
|
149
|
+
before do
|
|
150
|
+
stub_put("/users/1/unblock", "user_block_unblock")
|
|
151
|
+
@result = Gitlab.unblock_user(1)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should get the correct resource" do
|
|
155
|
+
expect(a_put("/users/1/unblock")).to have_been_made
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should return boolean" do
|
|
159
|
+
expect(@result).to eq(true)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe ".session" do
|
|
164
|
+
after do
|
|
165
|
+
Gitlab.endpoint = 'https://api.example.com'
|
|
166
|
+
Gitlab.private_token = 'secret'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
before do
|
|
170
|
+
stub_request(:post, "#{Gitlab.endpoint}/session").
|
|
171
|
+
to_return(body: load_fixture('session'), status: 200)
|
|
172
|
+
@session = Gitlab.session("email", "pass")
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
context "when endpoint is not set" do
|
|
176
|
+
it "should raise Error::MissingCredentials" do
|
|
177
|
+
Gitlab.endpoint = nil
|
|
178
|
+
expect do
|
|
179
|
+
Gitlab.session("email", "pass")
|
|
180
|
+
end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
context "when private_token is not set" do
|
|
185
|
+
it "should not raise Error::MissingCredentials" do
|
|
186
|
+
Gitlab.private_token = nil
|
|
187
|
+
expect { Gitlab.session("email", "pass") }.to_not raise_error
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
context "when endpoint is set" do
|
|
192
|
+
it "should get the correct resource" do
|
|
193
|
+
expect(a_request(:post, "#{Gitlab.endpoint}/session")).to have_been_made
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "should return information about a created session" do
|
|
197
|
+
expect(@session.email).to eq("john@example.com")
|
|
198
|
+
expect(@session.private_token).to eq("qEsq1pt6HJPaNciie3MG")
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
describe ".ssh_keys" do
|
|
204
|
+
context "with user ID passed" do
|
|
205
|
+
before do
|
|
206
|
+
stub_get("/users/1/keys", "keys")
|
|
207
|
+
@keys = Gitlab.ssh_keys({ user_id: 1 })
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "should get the correct resource" do
|
|
211
|
+
expect(a_get("/users/1/keys")).to have_been_made
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it "should return a paginated response of SSH keys" do
|
|
215
|
+
expect(@keys).to be_a Gitlab::PaginatedResponse
|
|
216
|
+
expect(@keys.first.title).to eq("narkoz@helium")
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context "without user ID passed" do
|
|
221
|
+
before do
|
|
222
|
+
stub_get("/user/keys", "keys")
|
|
223
|
+
@keys = Gitlab.ssh_keys
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it "should get the correct resource" do
|
|
227
|
+
expect(a_get("/user/keys")).to have_been_made
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "should return a paginated response of SSH keys" do
|
|
231
|
+
expect(@keys).to be_a Gitlab::PaginatedResponse
|
|
232
|
+
expect(@keys.first.title).to eq("narkoz@helium")
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
describe ".ssh_key" do
|
|
238
|
+
before do
|
|
239
|
+
stub_get("/user/keys/1", "key")
|
|
240
|
+
@key = Gitlab.ssh_key(1)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it "should get the correct resource" do
|
|
244
|
+
expect(a_get("/user/keys/1")).to have_been_made
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "should return information about an SSH key" do
|
|
248
|
+
expect(@key.title).to eq("narkoz@helium")
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
describe ".create_ssh_key" do
|
|
253
|
+
before do
|
|
254
|
+
stub_post("/user/keys", "key")
|
|
255
|
+
@key = Gitlab.create_ssh_key("title", "body")
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it "should get the correct resource" do
|
|
259
|
+
body = { title: "title", key: "body" }
|
|
260
|
+
expect(a_post("/user/keys").with(body: body)).to have_been_made
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "should return information about a created SSH key" do
|
|
264
|
+
expect(@key.title).to eq("narkoz@helium")
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
describe ".delete_ssh_key" do
|
|
269
|
+
before do
|
|
270
|
+
stub_delete("/user/keys/1", "key")
|
|
271
|
+
@key = Gitlab.delete_ssh_key(1)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it "should get the correct resource" do
|
|
275
|
+
expect(a_delete("/user/keys/1")).to have_been_made
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it "should return information about a deleted SSH key" do
|
|
279
|
+
expect(@key.title).to eq("narkoz@helium")
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
describe ".emails" do
|
|
284
|
+
describe "without user ID" do
|
|
285
|
+
before do
|
|
286
|
+
stub_get("/user/emails", "user_emails")
|
|
287
|
+
@emails = Gitlab.emails
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it "should get the correct resource" do
|
|
291
|
+
expect(a_get("/user/emails")).to have_been_made
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it "should return a information about a emails of user" do
|
|
295
|
+
email = @emails.first
|
|
296
|
+
expect(email.id).to eq 1
|
|
297
|
+
expect(email.email).to eq("email@example.com")
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
describe "with user ID" do
|
|
302
|
+
before do
|
|
303
|
+
stub_get("/users/2/emails", "user_emails")
|
|
304
|
+
@emails = Gitlab.emails(2)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
it "should get the correct resource" do
|
|
308
|
+
expect(a_get("/users/2/emails")).to have_been_made
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
it "should return a information about a emails of user" do
|
|
312
|
+
email = @emails.first
|
|
313
|
+
expect(email.id).to eq 1
|
|
314
|
+
expect(email.email).to eq("email@example.com")
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
describe ".email" do
|
|
320
|
+
before do
|
|
321
|
+
stub_get("/user/emails/2", "user_email")
|
|
322
|
+
@email = Gitlab.email(2)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "should get the correct resource" do
|
|
326
|
+
expect(a_get("/user/emails/2")).to have_been_made
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
it "should return a information about a email of user" do
|
|
330
|
+
expect(@email.id).to eq 1
|
|
331
|
+
expect(@email.email).to eq("email@example.com")
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
describe ".add_email" do
|
|
336
|
+
describe "without user ID" do
|
|
337
|
+
before do
|
|
338
|
+
stub_post("/user/emails", "user_email")
|
|
339
|
+
@email = Gitlab.add_email("email@example.com")
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
it "should get the correct resource" do
|
|
343
|
+
body = { email: "email@example.com" }
|
|
344
|
+
expect(a_post("/user/emails").with(body: body)).to have_been_made
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it "should return information about a new email" do
|
|
348
|
+
expect(@email.id).to eq(1)
|
|
349
|
+
expect(@email.email).to eq("email@example.com")
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
describe "with user ID" do
|
|
354
|
+
before do
|
|
355
|
+
stub_post("/users/2/emails", "user_email")
|
|
356
|
+
@email = Gitlab.add_email("email@example.com", 2)
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
it "should get the correct resource" do
|
|
360
|
+
body = { email: "email@example.com" }
|
|
361
|
+
expect(a_post("/users/2/emails").with(body: body)).to have_been_made
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
it "should return information about a new email" do
|
|
365
|
+
expect(@email.id).to eq(1)
|
|
366
|
+
expect(@email.email).to eq("email@example.com")
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
describe ".delete_email" do
|
|
372
|
+
describe "without user ID" do
|
|
373
|
+
before do
|
|
374
|
+
stub_delete("/user/emails/1", "user_email")
|
|
375
|
+
@email = Gitlab.delete_email(1)
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it "should get the correct resource" do
|
|
379
|
+
expect(a_delete("/user/emails/1")).to have_been_made
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it "should return information about a deleted email" do
|
|
383
|
+
expect(@email).to be_truthy
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
describe "with user ID" do
|
|
388
|
+
before do
|
|
389
|
+
stub_delete("/users/2/emails/1", "user_email")
|
|
390
|
+
@email = Gitlab.delete_email(1, 2)
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
it "should get the correct resource" do
|
|
394
|
+
expect(a_delete("/users/2/emails/1")).to have_been_made
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
it "should return information about a deleted email" do
|
|
398
|
+
expect(@email).to be_truthy
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
describe ".user_search" do
|
|
404
|
+
before do
|
|
405
|
+
stub_get("/users?search=User", "user_search")
|
|
406
|
+
@users = Gitlab.user_search('User')
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
it "should get the correct resource" do
|
|
410
|
+
expect(a_get("/users?search=User")).to have_been_made
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
it "should return an array of users found" do
|
|
414
|
+
expect(@users.first.id).to eq(1)
|
|
415
|
+
expect(@users.last.id).to eq(2)
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
end
|