Method: Conify::PlanChangeTest#call

Defined in:
lib/conify/test/plan_change_test.rb

#callObject

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/conify/test/plan_change_test.rb', line 7

def call
  external_uuid = data[:external_uuid]
  raise ArgumentError, 'Plan Change Test: No external_uuid specified' if external_uuid.nil?

  path = "#{base_path}/#{external_uuid.to_s}"
  payload = { plan: 'new_plan', conflux_id: data[:external_username] }

  test 'response' do
    code, _ = put(credentials, path, payload)

    if code == 200
      true
    elsif code == -1
      error "Plan Change Test: unable to connect to #{url}"
    else
      error "Plan Change Test: expected 200, got #{code}"
    end
  end

  test 'authentication' do
    code, _ = put(invalid_creds, path, payload)
    error "Plan Change Test: expected 401, got #{code}" if code != 401
    true
  end
end