require_relative '../test_config' require 'helix_versioning_engine' require 'hws_settings' describe 'HelixVersioningEngine commands' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end context 'GET /p4/v78/commands/:command' do it 'should return a 403 for commands that are not whitelisted' do authorize 'jdoe', ticket_for_jdoe get('/p4/v78/commands/sync') expect(last_response.status).to eq(403) end it 'should return a 403 for commands that are missing required args' do authorize 'jdoe', ticket_for_jdoe get('/p4/v78/commands/files') expect(last_response.status).to eq(403) end it 'should allow you to run a whitelisted command, specified via a string' do authorize 'jdoe', ticket_for_jdoe get('/p4/v78/commands/info') expect(last_response.status).to eq(200) end it 'should allow you to run a whitelisted command if you specify a ' + 'required argument via an array' do authorize 'jdoe', ticket_for_jdoe depot_path = Cloud::Settings.cloud_enabled? ? '//my_project/main' : '//depot' get("/p4/v78/commands/files?arg1=-m&arg2=10&arg3=#{depot_path}/.../README") expect(last_response.status).to eq(200) end end context 'POST /p4/v78/commands/:command' do it 'should return a 403 for commands that are not whitelisted' do authorize 'jdoe', ticket_for_jdoe post('/p4/v78/commands/sync') expect(last_response.status).to eq(403) end end end