require_relative '../test_config' require 'helix_versioning_engine' describe 'HelixVersioningEngine users' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end rand_str = (0...8).map { (65 + rand(26)).chr }.join new_user = { 'User' => "test_#{rand_str}", 'FullName' => "Test User #{rand_str}", 'Email' => "test_#{rand_str}@example.com" } context 'GET /helix_versioning_engine/v78/users' do it 'should list jdoe and super users' do authorize 'super', ticket_for_super get('/helix_versioning_engine/v78/users') expect(last_response.status).to eq(200) users = JSON.parse(last_response.body) expect(users.map { |x| x['User'] }).to include('jdoe') expect(users.map { |x| x['User'] }).to include('super') end end context 'GET /helix_versioning_engine/v78/users/:user' do it 'should return the user mmustermann' do authorize 'super', ticket_for_super get('/helix_versioning_engine/v78/users/mmustermann') expect(last_response.status).to eq(200) user = JSON.parse(last_response.body) expect(user['User']).to eq('mmustermann') expect(user['FullName']).to eq('Max Mustermann') end end context 'POST /helix_versioning_engine/v78/users' do it 'should create a new user' do authorize 'super', ticket_for_super post('/helix_versioning_engine/v78/users', new_user) expect(last_response.status).to eq(200) get("/helix_versioning_engine/v78/users/#{new_user['User']}") expect(last_response.status).to eq(200) user = JSON.parse(last_response.body) expect(user['FullName']).to eq(new_user['FullName']) end end context 'PATCH /helix_versioning_engine/v78/users/:user' do it 'should update a user email' do authorize 'super', ticket_for_super patch('/helix_versioning_engine/v78/users/mmustermann', {'Email' => "max_power_#{rand_str}@example.com"}) expect(last_response.status).to eq(200) get('/helix_versioning_engine/v78/users/mmustermann') expect(last_response.status).to eq(200) user = JSON.parse(last_response.body) expect(user['Email']).to eq("max_power_#{rand_str}@example.com") end it 'should return a 404 if you attempt to patch an invalid user' do authorize 'super', ticket_for_super patch('/helix_versioning_engine/v78/users/invalid', {'Email' => "max_power_#{rand_str}@example.com"}) expect(last_response.status).to eq(404) end end context 'DELETE /helix_versioning_engine/v78/users/:user' do it 'should delete the user' do authorize 'super', ticket_for_super delete("/helix_versioning_engine/v78/users/#{new_user['User']}") expect(last_response.status).to eq(200) get("/helix_versioning_engine/v78/users/#{new_user['User']}") expect(last_response.status).to eq(404) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services/spec/helix_versioning_engine/users_spec.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/spec/helix_versioning_engine/users_spec.rb | |||||
#3 | 15240 | tjuricek |
Set api level via request path on all Helix Versioning Engine methods. This will allow migration of applications to different P4D versions. Our internal methods (like project API) should attempt to handle backward compatibility similarly. P4WEBAPI-118 |
||
#2 | 15227 | tjuricek |
Revise implementation, tests, and documentation for protections management. Remove some specs I will not be revising from the helix_web_services project. |
||
#1 | 15185 | tjuricek | Update user spec management implementation, tests, and documentation. |