audc-gerry 0.1.6
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/README.md +62 -0
- data/Rakefile +7 -0
- data/lib/gerry/api/access.rb +17 -0
- data/lib/gerry/api/accounts.rb +38 -0
- data/lib/gerry/api/branches.rb +45 -0
- data/lib/gerry/api/changes.rb +38 -0
- data/lib/gerry/api/groups.rb +72 -0
- data/lib/gerry/api/projects.rb +73 -0
- data/lib/gerry/api/request.rb +86 -0
- data/lib/gerry/client.rb +58 -0
- data/lib/gerry/version.rb +5 -0
- data/lib/gerry.rb +12 -0
- data/spec/access_spec.rb +15 -0
- data/spec/accounts_spec.rb +36 -0
- data/spec/branches_spec.rb +36 -0
- data/spec/changes_spec.rb +55 -0
- data/spec/fixtures/README.md.json +2 -0
- data/spec/fixtures/access_rights.json +250 -0
- data/spec/fixtures/account_groups.json +33 -0
- data/spec/fixtures/branch_access.json +50 -0
- data/spec/fixtures/capabilities.json +7 -0
- data/spec/fixtures/changes.json +31 -0
- data/spec/fixtures/changes_batch_0.json +18 -0
- data/spec/fixtures/changes_batch_1.json +18 -0
- data/spec/fixtures/changes_batch_2.json +17 -0
- data/spec/fixtures/group_members.json +15 -0
- data/spec/fixtures/groups.json +69 -0
- data/spec/fixtures/open_changes.json +17 -0
- data/spec/fixtures/project_branch.json +6 -0
- data/spec/fixtures/project_branches.json +21 -0
- data/spec/fixtures/project_head.json +2 -0
- data/spec/fixtures/projects.json +9 -0
- data/spec/fixtures/query_capabilities.json +5 -0
- data/spec/groups_spec.rb +92 -0
- data/spec/projects_spec.rb +90 -0
- data/spec/request_spec.rb +46 -0
- data/spec/spec_helper.rb +50 -0
- metadata +234 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe '.projects' do
|
5
|
+
before(:all) do
|
6
|
+
@client = MockGerry.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should fetch all projects' do
|
10
|
+
stub = stub_get('/projects/', 'projects.json')
|
11
|
+
|
12
|
+
projects = @client.projects
|
13
|
+
|
14
|
+
expect(stub).to have_been_requested
|
15
|
+
|
16
|
+
expect(projects['awesome']['description']).to eq('Awesome project')
|
17
|
+
expect(projects['clean']['description']).to eq('Clean code!')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should fetch a project' do
|
21
|
+
stub = stub_get('/projects/awesome', 'projects.json')
|
22
|
+
|
23
|
+
projects = @client.find_project('awesome')
|
24
|
+
|
25
|
+
expect(stub).to have_been_requested
|
26
|
+
|
27
|
+
expect(projects['awesome']['description']).to eq('Awesome project')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should fetch file content' do
|
31
|
+
stub = stub_get('/projects/awesome/commits/djfkslj/files/README.md/content','README.md.json')
|
32
|
+
|
33
|
+
file = @client.project_file('awesome','djfkslj','README.md')
|
34
|
+
|
35
|
+
expect(stub).to have_been_requested
|
36
|
+
expect(file).to eq('Hello World!')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should resolve the symbolic HEAD ref of a project' do
|
40
|
+
project = 'awesome'
|
41
|
+
stub = stub_get("/projects/#{project}/HEAD", 'project_head.json')
|
42
|
+
|
43
|
+
branch = @client.get_head(project)
|
44
|
+
|
45
|
+
expect(stub).to have_been_requested
|
46
|
+
|
47
|
+
expect(branch).to eq('refs/heads/stable')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should define the symbolic HEAD ref of a project' do
|
51
|
+
project = 'awesome'
|
52
|
+
branch = 'stable'
|
53
|
+
input = {
|
54
|
+
ref: 'refs/heads/' + branch
|
55
|
+
}
|
56
|
+
stub = stub_put("/projects/#{project}/HEAD", input.to_json, get_fixture('project_head.json'))
|
57
|
+
|
58
|
+
new_branch = @client.set_head(project, branch)
|
59
|
+
|
60
|
+
expect(stub).to have_been_requested
|
61
|
+
|
62
|
+
expect(new_branch).to eq('refs/heads/' + branch)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'list access rights' do
|
66
|
+
stub = stub_get('/projects/foo/access', 'branch_access.json')
|
67
|
+
|
68
|
+
accesses = @client.project_access('foo')
|
69
|
+
expect(stub).to have_been_requested
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'create project access rights' do
|
73
|
+
access_rights = {
|
74
|
+
'refs/heads/*' => {
|
75
|
+
'permissions' => {
|
76
|
+
'read' => {
|
77
|
+
'rules' => {
|
78
|
+
'user:kobe' => {
|
79
|
+
'action' => 'ALLOW'
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
stub = stub_post('/projects/foo/access', 'add' => access_rights)
|
87
|
+
@client.create_project_access('foo', access_rights)
|
88
|
+
expect(stub).to have_been_requested
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '.map_options' do
|
4
|
+
it 'should map the query options' do
|
5
|
+
|
6
|
+
client = MockGerry.new
|
7
|
+
options = client.map_options(['q=createAccount', 'q=createGroup'])
|
8
|
+
|
9
|
+
expect(options).to eq('q=createAccount&q=createGroup')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.get' do
|
14
|
+
it 'should request projects as anoymous' do
|
15
|
+
stub = stub_get('/projects/', 'projects.json')
|
16
|
+
|
17
|
+
client = MockGerry.new
|
18
|
+
client.projects
|
19
|
+
|
20
|
+
expect(stub).to have_been_requested
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should request projects as user with basic auth' do
|
24
|
+
username = 'gerry'
|
25
|
+
password = 'whoop'
|
26
|
+
|
27
|
+
body = get_fixture('projects.json')
|
28
|
+
|
29
|
+
stub = stub_request(:get, 'http://localhost/a/projects/').
|
30
|
+
with(
|
31
|
+
headers:
|
32
|
+
{
|
33
|
+
'Accept' => 'application/json',
|
34
|
+
'Authorization' => 'Basic Z2Vycnk6d2hvb3A='
|
35
|
+
}
|
36
|
+
).to_return(:status => 200, :body => body, :headers => {})
|
37
|
+
|
38
|
+
client = Gerry.new(MockGerry::URL, 'gerry', 'whoop')
|
39
|
+
projects = client.projects
|
40
|
+
|
41
|
+
expect(stub).to have_been_requested
|
42
|
+
|
43
|
+
expect(projects['awesome']['description']).to eq('Awesome project')
|
44
|
+
expect(projects['clean']['description']).to eq('Clean code!')
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "rspec/expectations"
|
2
|
+
require 'webmock/rspec'
|
3
|
+
|
4
|
+
require_relative '../lib/gerry'
|
5
|
+
|
6
|
+
class MockGerry < Gerry::Client
|
7
|
+
URL = 'http://localhost'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super(URL)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_fixture(filename)
|
15
|
+
return '' if filename.empty?
|
16
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
17
|
+
File.read(file_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def stub_get(url, filename)
|
21
|
+
body = get_fixture(filename)
|
22
|
+
stub_request(:get, "#{MockGerry::URL}#{url}").
|
23
|
+
to_return(:status => 200, :body => "#{body}", :headers => {'Content-Type' => 'application/json'})
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_put(url, body, response_body=nil)
|
27
|
+
response = {
|
28
|
+
status: 200,
|
29
|
+
headers: {
|
30
|
+
'Content-Type' => 'application/json'
|
31
|
+
},
|
32
|
+
body: response_body
|
33
|
+
}
|
34
|
+
stub_request(:put, "#{MockGerry::URL}#{url}").
|
35
|
+
with(:body => body, :headers => { 'Content-Type' => 'application/json' }).
|
36
|
+
to_return(response)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stub_post(url, body, response_body=nil)
|
40
|
+
response = {
|
41
|
+
status: 200,
|
42
|
+
headers: {
|
43
|
+
'Content-Type' => 'application/json'
|
44
|
+
},
|
45
|
+
body: response_body
|
46
|
+
}
|
47
|
+
stub_request(:post, "#{MockGerry::URL}#{url}").
|
48
|
+
with(:body => body, :headers => { 'Content-Type' => 'application/json' }).
|
49
|
+
to_return(response)
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: audc-gerry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabian Mettler
|
8
|
+
- Andrew Erickson
|
9
|
+
- Travis Truman
|
10
|
+
- Sebastian Schuberth
|
11
|
+
- Orgad Shaneh
|
12
|
+
- iiithking
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: httparty
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rake
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
type: :development
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rack-test
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: webmock
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: guard
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: guard-rspec
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
type: :development
|
110
|
+
prerelease: false
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: rb-readline
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: pry
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
type: :development
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
description: " Simple Ruby wrapper for the Gerrit Code Review REST-API.\n"
|
145
|
+
email: trumant@gmail.com
|
146
|
+
executables: []
|
147
|
+
extensions: []
|
148
|
+
extra_rdoc_files: []
|
149
|
+
files:
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- lib/gerry.rb
|
153
|
+
- lib/gerry/api/access.rb
|
154
|
+
- lib/gerry/api/accounts.rb
|
155
|
+
- lib/gerry/api/branches.rb
|
156
|
+
- lib/gerry/api/changes.rb
|
157
|
+
- lib/gerry/api/groups.rb
|
158
|
+
- lib/gerry/api/projects.rb
|
159
|
+
- lib/gerry/api/request.rb
|
160
|
+
- lib/gerry/client.rb
|
161
|
+
- lib/gerry/version.rb
|
162
|
+
- spec/access_spec.rb
|
163
|
+
- spec/accounts_spec.rb
|
164
|
+
- spec/branches_spec.rb
|
165
|
+
- spec/changes_spec.rb
|
166
|
+
- spec/fixtures/README.md.json
|
167
|
+
- spec/fixtures/access_rights.json
|
168
|
+
- spec/fixtures/account_groups.json
|
169
|
+
- spec/fixtures/branch_access.json
|
170
|
+
- spec/fixtures/capabilities.json
|
171
|
+
- spec/fixtures/changes.json
|
172
|
+
- spec/fixtures/changes_batch_0.json
|
173
|
+
- spec/fixtures/changes_batch_1.json
|
174
|
+
- spec/fixtures/changes_batch_2.json
|
175
|
+
- spec/fixtures/group_members.json
|
176
|
+
- spec/fixtures/groups.json
|
177
|
+
- spec/fixtures/open_changes.json
|
178
|
+
- spec/fixtures/project_branch.json
|
179
|
+
- spec/fixtures/project_branches.json
|
180
|
+
- spec/fixtures/project_head.json
|
181
|
+
- spec/fixtures/projects.json
|
182
|
+
- spec/fixtures/query_capabilities.json
|
183
|
+
- spec/groups_spec.rb
|
184
|
+
- spec/projects_spec.rb
|
185
|
+
- spec/request_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
homepage: http://github.com/trumant/gerry
|
188
|
+
licenses: []
|
189
|
+
metadata: {}
|
190
|
+
post_install_message:
|
191
|
+
rdoc_options: []
|
192
|
+
require_paths:
|
193
|
+
- lib
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
requirements: []
|
205
|
+
rubygems_version: 3.3.26
|
206
|
+
signing_key:
|
207
|
+
specification_version: 4
|
208
|
+
summary: Simple Ruby wrapper for the Gerrit Code Review REST-API.
|
209
|
+
test_files:
|
210
|
+
- spec/access_spec.rb
|
211
|
+
- spec/accounts_spec.rb
|
212
|
+
- spec/branches_spec.rb
|
213
|
+
- spec/changes_spec.rb
|
214
|
+
- spec/fixtures/README.md.json
|
215
|
+
- spec/fixtures/access_rights.json
|
216
|
+
- spec/fixtures/account_groups.json
|
217
|
+
- spec/fixtures/branch_access.json
|
218
|
+
- spec/fixtures/capabilities.json
|
219
|
+
- spec/fixtures/changes.json
|
220
|
+
- spec/fixtures/changes_batch_0.json
|
221
|
+
- spec/fixtures/changes_batch_1.json
|
222
|
+
- spec/fixtures/changes_batch_2.json
|
223
|
+
- spec/fixtures/group_members.json
|
224
|
+
- spec/fixtures/groups.json
|
225
|
+
- spec/fixtures/open_changes.json
|
226
|
+
- spec/fixtures/project_branch.json
|
227
|
+
- spec/fixtures/project_branches.json
|
228
|
+
- spec/fixtures/project_head.json
|
229
|
+
- spec/fixtures/projects.json
|
230
|
+
- spec/fixtures/query_capabilities.json
|
231
|
+
- spec/groups_spec.rb
|
232
|
+
- spec/projects_spec.rb
|
233
|
+
- spec/request_spec.rb
|
234
|
+
- spec/spec_helper.rb
|