ssh_access_controller_spec.rb revision f198c0ec200763fe1b0db998cd9418f412be8361
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenrequire 'spec_helper'
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'should return valid response when encountering error' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen get :index, repository_id: repository.to_param, key_id: nil, permission: 'write'
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen context 'should return false-permission on valid request without access permission' do
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen get :index, repository_id: repository.to_param, key_id: key.id.to_s, permission: 'write'
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen expect(response.body).to include('"allowed":false')
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen expect(response.body).not_to include('reason')
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen context 'should return true-permission on valid request with access permission' do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen get :index, repository_id: repository.to_param, key_id: key.id.to_s, permission: 'read'
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen expect(response.body).to include('"allowed":true')
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen expect(response.body).not_to include('reason')
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen context 'should return false-permission on valid request with write to mirror' do
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen let(:repository) { create :repository, source_address: 'http://some_source_address.example.com', source_type: 'git' }
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen get :index, repository_id: repository.to_param, key_id: key.id.to_s, permission: 'write'
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen expect(response.body).to include('"allowed":false')
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen it 'contains error message which is suitable for the user' do
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen expect(response.body).to include('"provide_to_user":true')