Skip to content

Commit becafb3

Browse files
GbArcAndriiMyskogbarc-dt
authored
memberships (#1375)
* Add default artifact manager config * expose membership /build_permission * specs --------- Co-authored-by: AndriiMysko <[email protected]> Co-authored-by: GbArc <[email protected]>
1 parent e487b81 commit becafb3

File tree

9 files changed

+22
-14
lines changed

9 files changed

+22
-14
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Travis::API::V3
2+
class Renderer::Membership < ModelRenderer
3+
representation(:minimal, :organization_id, :build_permission)
4+
representation(:standard, :user_id, :organization_id, :role, :build_permission)
5+
end
6+
end

lib/travis/api/v3/renderer/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Travis::API::V3
44
class Renderer::User < Renderer::Owner
5-
representation(:standard, :email, :is_syncing, :synced_at, :recently_signed_up, :secure_user_hash, :ro_mode, :confirmed_at, :custom_keys, :internal, :last_activity_at)
5+
representation(:standard, :email, :is_syncing, :synced_at, :recently_signed_up, :secure_user_hash, :ro_mode, :confirmed_at, :custom_keys, :internal, :last_activity_at, :memberships)
66
representation(:additional, :emails, :collaborator)
77

88
def email

lib/travis/api/v3/services/custom_images/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run!
99
raise NotFound unless owner
1010

1111
if owner.is_a?(Travis::API::V3::Models::User)
12-
access_control.permissions(owner).write!
12+
access_control.permissions(owner).sync!
1313
else
1414
access_control.permissions(owner).admin!
1515
end

spec/v3/artifact_manager_client_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@
1111

1212
describe '#delete_images' do
1313
let(:image_ids) { [1, 2, 3] }
14-
subject { client.delete_images(image_ids) }
14+
subject { client.delete_images('user', user_id, image_ids) }
1515

1616
it 'sends a DELETE request to the artifact manager' do
17-
stub_request(:delete, "#{url}/images")
18-
.with(body: { image_ids: image_ids }.to_json, headers: { 'X-Travis-User-Id' => user_id.to_s })
19-
.to_return(status: 200, body: { images: [] }.to_json, headers: { 'Content-Type' => 'application/json' })
17+
stub_request(:delete, %r{#{url}/image/user/#{user_id}/\d+})
18+
.to_return(status: 200, headers: { 'Content-Type' => 'application/json' })
2019

2120
subject
2221
end
2322

2423
it 'raises an error if the request fails' do
25-
stub_request(:delete, "#{url}/images")
26-
.with(body: { image_ids: image_ids }.to_json, headers: { 'X-Travis-User-Id' => user_id.to_s })
24+
stub_request(:delete, %r{#{url}/image/user/#{user_id}/\d+})
2725
.to_return(status: 400, body: { error: 'Bad Request' }.to_json, headers: { 'Content-Type' => 'application/json' })
2826

2927
expect { subject }.to raise_error(Travis::API::V3::ClientError, 'Bad Request')

spec/v3/services/custom_images/delete_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
context 'authenticated' do
1616
describe "deleting custom images by id list" do
1717
before do
18-
stub_request(:delete, "#{Travis.config.artifact_manager.url}/images")
19-
.with(
20-
body: { image_ids: ['1', '2', '3'] }.to_json,
21-
headers: { 'X-Travis-User-Id' => user.id.to_s }
22-
)
18+
stub_request(:delete, %r{#{Travis.config.artifact_manager.url}/image/user/#{user.id}/\d+})
2319
.to_return(status: 204, headers: { 'Content-Type' => 'application/json' })
2420
end
2521

spec/v3/services/custom_images/for_owner_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
let(:authorization) { { 'permissions' => [ 'repository_state_update' ] } }
3737

3838
it 'returns an empty list' do
39-
get("/v3/owner/#{other_user.login}/custom_images", {}, json_headers.merge('HTTP_AUTHORIZATION' => "token #{other_user_token}"))
39+
get("/v3/owner/#{user.login}/custom_images", {}, json_headers.merge('HTTP_AUTHORIZATION' => "token #{other_user_token}"))
4040

4141
expect(JSON.parse(last_response.body)).to include(
4242
'error_type' => 'insufficient_access'

spec/v3/services/installation/find_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"vcs_type" => user.vcs_type,
6262
"avatar_url" => "https://0.gravatar.com/avatar/07fb84848e68b96b69022d333ca8a3e2",
6363
"is_syncing" => nil,
64+
"memberships" => [],
6465
"synced_at" => nil,
6566
"education" => nil,
6667
"allowance" => {

spec/v3/services/owner/find_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@
442442
"vcs_type" => user.vcs_type,
443443
"avatar_url" => nil,
444444
"is_syncing" => nil,
445+
"memberships" => [],
445446
"synced_at" => nil,
446447
"education" => nil,
447448
"allow_migration"=> false,
@@ -480,6 +481,7 @@
480481
"avatar_url" => nil,
481482
"education" => nil,
482483
"is_syncing" => nil,
484+
"memberships" => [],
483485
"synced_at" => nil,
484486
"allow_migration"=> false,
485487
"allowance" => {
@@ -517,6 +519,7 @@
517519
"avatar_url" => nil,
518520
"education" => nil,
519521
"is_syncing" => nil,
522+
"memberships" => [],
520523
"synced_at" => nil,
521524
"allow_migration" => false,
522525
"allowance" => {
@@ -561,6 +564,7 @@
561564
"avatar_url" => nil,
562565
"education" => nil,
563566
"is_syncing" => nil,
567+
"memberships" => [],
564568
"synced_at" => nil,
565569
"allow_migration" => false,
566570
"allowance" => {

spec/v3/services/v2_subscription/executions_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
"account_env_vars" => [],
212212
"email"=>"[email protected]",
213213
"is_syncing"=>nil,
214+
"memberships"=>[],
214215
"synced_at"=>nil,
215216
"recently_signed_up"=>false,
216217
"secure_user_hash"=>nil,
@@ -271,6 +272,7 @@
271272
"account_env_vars" => [],
272273
"email"=>"[email protected]",
273274
"is_syncing"=>nil,
275+
"memberships"=>[],
274276
"synced_at"=>nil,
275277
"recently_signed_up"=>false,
276278
"secure_user_hash"=>nil,
@@ -310,6 +312,7 @@
310312
"account_env_vars" => [],
311313
"email"=>"[email protected]",
312314
"is_syncing"=>nil,
315+
"memberships"=>[],
313316
"synced_at"=>nil,
314317
"recently_signed_up"=>false,
315318
"secure_user_hash"=>nil,

0 commit comments

Comments
 (0)