Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Stick the staging task id in request headers for services requests
Browse files Browse the repository at this point in the history
This is more in keeping with current practices of sticking auth tokens
into header fields.

Test plan:
- Updated unit test passes.

Change-Id: I7e190f3db9f85b13b8fba59ee81d3fd233c0fbfb
  • Loading branch information
mpage committed Nov 7, 2011
1 parent 23be293 commit f970aef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cloud_controller/app/controllers/services_controller.rb
Expand Up @@ -248,7 +248,8 @@ def unbind


def require_user_or_staging_task_id def require_user_or_staging_task_id
unless user unless user
staging_task = StagingTask.find_task(params[:staging_task_id]) staging_task_id = request.headers['X_VCAP_STAGING_TASK_ID']
staging_task = StagingTask.find_task(staging_task_id)
@current_user = staging_task.user if staging_task @current_user = staging_task.user if staging_task
end end
raise CloudError.new(CloudError::FORBIDDEN) unless user raise CloudError.new(CloudError::FORBIDDEN) unless user
Expand Down
Expand Up @@ -407,7 +407,7 @@ def unbind_instance(service_id, handle_id, binding_options)
end end


it 'should set the user for the request to the user associated with the supplied staging task' do it 'should set the user for the request to the user associated with the supplied staging task' do
@controller.stubs(:params).returns({:staging_task_id => 1}) request.env['X_VCAP_STAGING_TASK_ID'] = 1
mock_task = mock() mock_task = mock()
mock_task.expects(:user).returns(@user) mock_task.expects(:user).returns(@user)
StagingTask.expects(:find_task).with(1).returns(mock_task) StagingTask.expects(:find_task).with(1).returns(mock_task)
Expand Down

0 comments on commit f970aef

Please sign in to comment.