require_relative '../test_config' require 'hws_settings' require 'helix_sync' require 'base64' describe 'HelixSync clients' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end my_project_id = HWSStrings.component_encode('My Project') device_client_info = { device: 'test_device', root: '/dev/null' } after(:each) do HWSSettings.settings_handle.HVE_PROJECTS_PATH = nil end context 'POST /helix-sync/v1/:project/clients/device' do context 'no implementation' do it 'returns a 404' do if Cloud::Settings.cloud_enabled? skip 'cloud does not need the HVE... setting' end authorize 'jdoe', ticket_for_jdoe post("/helix-sync/v1/#{my_project_id}/clients/device", device_client_info) expect(last_response.status).to eq(404) end end context 'HVE projects' do it 'can create a project' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' authorize 'jdoe', ticket_for_jdoe post("/helix-sync/v1/#{my_project_id}/clients/device", device_client_info) expect(last_response.status).to eq(200) client_data = JSON.parse(last_response.body) expect(client_data['client']).to include(my_project_id) expect(client_data['client']).to include(device_client_info[:device]) expect(client_data['client']).to include('jdoe') end end end context 'POST /helix-sync/v1/:project/clients/shelf' do context 'no implementation' do it 'returns a 404' do if Cloud::Settings.cloud_enabled? skip 'cloud does not need the HVE... setting' end authorize 'jdoe', ticket_for_jdoe post("/helix-sync/v1/#{my_project_id}/clients/shelf") expect(last_response.status).to eq(404) end end context 'HVE projects' do it 'can create a project' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' authorize 'jdoe', ticket_for_jdoe post("/helix-sync/v1/#{my_project_id}/clients/shelf") expect(last_response.status).to eq(200) end end end end