Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/katello/api/v2/content_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def create
param :offset, :number, :required => true, :desc => N_("The offset in the file where the content starts")
param :content, File, :required => true, :desc => N_("The actual file contents")
def update
content = params[:content].respond_to?(:read) ? params[:content].read : params[:content]
@repository.backend_content_service(::SmartProxy.pulp_primary)
.upload_chunk(params[:id], params[:offset], params[:content], params[:size])
.upload_chunk(params[:id], params[:offset], content, params[:size])
head :no_content
end

Expand Down
12 changes: 12 additions & 0 deletions test/controllers/api/v2/content_uploads_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ def test_update
assert_response :success
end

def test_update_file
id = '1'
offset = '0'
test_document = File.join(Engine.root, "test", "fixtures", "files", "puppet_module.tar.gz")
content = Rack::Test::UploadedFile.new(test_document, '')
file_content = File.read(test_document)
@repo.backend_content_service(SmartProxy.pulp_primary).expects(:upload_chunk).with(id, offset, file_content, nil)
put :update, params: { :id => id, :offset => offset, :content => content, :repository_id => @repo.id }

assert_response :success
end

def test_update_protected
allowed_perms = [@update_permission]
denied_perms = [@read_permission, @create_permission, @destroy_permission]
Expand Down