#192: added new specs, updated Platform API controller
This commit is contained in:
parent
38a4729cbc
commit
828ddc540f
|
@ -7,7 +7,8 @@ class Api::V1::PlatformsController < Api::V1::BaseController
|
||||||
load_and_authorize_resource :except => :allowed
|
load_and_authorize_resource :except => :allowed
|
||||||
|
|
||||||
def allowed
|
def allowed
|
||||||
platform_name = (params[:path] || '').match(/^\/#{Platform::NAME_PATTERN}\//)
|
platform_name = (params[:path] || '').gsub(/^[\/]+/, '')
|
||||||
|
.match(/^(#{Platform::NAME_PATTERN}\/|#{Platform::NAME_PATTERN}$)/)
|
||||||
render(:inline => 'true') && return unless platform_name
|
render(:inline => 'true') && return unless platform_name
|
||||||
platform_name = platform_name[0].gsub(/\//, '')
|
platform_name = platform_name[0].gsub(/\//, '')
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,30 @@ describe Api::V1::PlatformsController do
|
||||||
response.status.should == 403
|
response.status.should == 403
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'ensures that status 403 if no token and a lot of "/"' do
|
||||||
|
get :allowed, :path => "///#{@platform.name}///repository/SRPMS/base/release/repodata/"
|
||||||
|
response.status.should == 403
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ensures that status 200 if token correct and a lot of "/"' do
|
||||||
|
token = FactoryGirl.create(:platform_token, :subject => @platform)
|
||||||
|
http_login token.authentication_token, ''
|
||||||
|
get :allowed, :path => "///#{@platform.name}///repository/SRPMS/base/release/repodata/"
|
||||||
|
response.status.should == 200
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ensures that status 403 on access to root of platform if no token' do
|
||||||
|
get :allowed, :path => "///#{@platform.name}"
|
||||||
|
response.status.should == 403
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'ensures that status 200 on access to root of platform if token correct' do
|
||||||
|
token = FactoryGirl.create(:platform_token, :subject => @platform)
|
||||||
|
http_login token.authentication_token, ''
|
||||||
|
get :allowed, :path => "///#{@platform.name}"
|
||||||
|
response.status.should == 200
|
||||||
|
end
|
||||||
|
|
||||||
it 'ensures that status 403 if wrong token' do
|
it 'ensures that status 403 if wrong token' do
|
||||||
http_login 'KuKu', ''
|
http_login 'KuKu', ''
|
||||||
get :allowed, :path => "/#{@platform.name}/repository/SRPMS/base/release/repodata/"
|
get :allowed, :path => "/#{@platform.name}/repository/SRPMS/base/release/repodata/"
|
||||||
|
|
Loading…
Reference in New Issue