servers_spec.rb #2

  • //
  • guest/
  • doug_scheirer/
  • helix-web-services/
  • main/
  • source/
  • helix_web_services/
  • spec/
  • helix_versioning_engine/
  • servers_spec.rb
  • View
  • Commits
  • Open Download .zip Download (2 KB)
require_relative '../test_config'

require 'helix_versioning_engine'

describe 'HelixVersioningEngine servers' do
  include Rack::Test::Methods

  randstr = (0...8).map { (65 + rand(26)).chr }.join
  server_id = "test_#{randstr}"

  new_server = {
      'ServerID' => server_id,
      'Description' => "test server #{server_id}",
      'Type' => 'server',
      'Services' => 'standard'
  }

  def app
    HELIX_WEB_SERVICES_APP
  end

  context 'POST /p4/v78/servers' do
    it 'can create a test server' do
      authorize 'super', ticket_for_super
      post('/p4/v78/servers', new_server)
      expect(last_response.status).to eq(200)
    end
  end

  context 'GET /p4/v78/servers' do
    it 'can find the new server in an array of servers' do
      authorize 'super', ticket_for_super
      get('/p4/v78/servers')
      expect(last_response.status).to eq(200)

      results = JSON.parse(last_response.body)

      server_ids = results.map { |x| x['ServerID'] }
      expect(server_ids).to include(server_id)
    end
  end

  context 'PATCH /p4/v78/servers/[server]' do
    it 'can update the users list' do
      authorize 'super', ticket_for_super
      patch("/p4/v78/servers/#{server_id}",
            'Description' => "Update server #{server_id}")
      expect(last_response.status).to eq(200)
    end
  end

  context 'GET /p4/v78/servers/[server]' do
    it 'can load the new server with a View' do
      authorize 'super', ticket_for_super
      get("/p4/v78/servers/#{server_id}")
      expect(last_response.status).to eq(200)

      obj = JSON.parse(last_response.body)

      expect(obj['ServerID']).to eq(server_id)
      expect(obj['Description']).to include("Update server #{server_id}")
    end
  end

  context 'DELETE /p4/v78/servers/[server]' do
    it 'can delete the server' do
      authorize 'super', ticket_for_super
      delete("/p4/v78/servers/#{server_id}")
      expect(last_response.status).to eq(200)

      get('/p4/v78/servers')
      expect(last_response.status).to eq(200)

      results = JSON.parse(last_response.body)

      server_ids = results.map { |x| x['ServerID'] }
      expect(server_ids).to_not include(server_id)
    end
  end
end
# Change User Description Committed
#2 16114 Doug Scheirer Merge from main
#1 15688 Doug Scheirer Populate -o //guest/perforce_software/helix-web-services/...
//guest/doug_scheirer/helix-web-services/....
//guest/perforce_software/helix-web-services/main/source/helix_web_services/spec/helix_versioning_engine/servers_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/servers_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 15222 tjuricek Revise server specs testing and documentation.

Note: also fixed issues with setting P4PORT via headers. For whatever reason, the host setting doesn't seem to work like I expect it to, though P4PORT works just fine.