Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 434e922

Browse files
author
Sannidhi Jalukar
committed
Return 422 for package copy when image registry is used
[#175023018] https://www.pivotaltracker.com/story/show/175023018 Authored-by: Sannidhi Jalukar <sjalukar@pivotal.io>
1 parent 3d00d22 commit 434e922

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

app/controllers/v3/packages_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def create_fresh
161161
end
162162

163163
def create_copy
164+
unprocessable!('Unable to copy package when an image registry is used to store packages') if VCAP::CloudController::Config.config.package_image_registry_configured?
165+
164166
app_guid = JSON.parse(request.body).deep_symbolize_keys.dig(:relationships, :app, :data, :guid)
165167
destination_app = AppModel.where(guid: app_guid).eager(:space, :organization).first
166168
unprocessable_app! unless destination_app &&

spec/unit/controllers/v3/packages_controller_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,19 @@
12971297
allow_user_write_access(user, space: destination_space)
12981298
end
12991299

1300+
context 'when the package is stored in an image registry' do
1301+
before do
1302+
TestConfig.override({ packages: { image_registry: { base_path: 'hub.example.com/user' } } })
1303+
end
1304+
1305+
it 'returns 422' do
1306+
post :create, params: { source_guid: original_package.guid }.merge(relationship_request_body), as: :json
1307+
1308+
expect(response.status).to eq 422
1309+
expect(response.body).to include('UnprocessableEntity')
1310+
end
1311+
end
1312+
13001313
it 'returns a 201 and the response' do
13011314
expect(target_app_model.packages.count).to eq(0)
13021315

0 commit comments

Comments
 (0)