Class: Conify::ApiTest

Inherits:
Test
  • Object
show all
Includes:
HTTPForTests
Defined in:
lib/conify/test/api_test.rb

Instance Attribute Summary

Attributes inherited from Test

#data

Instance Method Summary collapse

Methods included from HTTPForTests

#delete, #get, #post, #put, #request

Methods inherited from Test

#api_requires?, #env, #initialize, #run, #test, #url

Methods included from Helpers

#allow_user_response, #ask_for_conflux_creds, #ask_for_password, #ask_for_password_on_windows, #camelize, #display, #echo_off, #echo_on, #error, #exclusive_deep_merge, #format_with_bang, #host, #host_url, #kensa_manifest_name, #kensa_manifest_path, #manifest_content, #manifest_filename, #manifest_path, #manually_added_methods, #open_url, #running_on_a_mac?, #running_on_windows?, #site_url, #to_table, #with_tty

Constructor Details

This class inherits a constructor from Conify::Test

Instance Method Details

#base_pathObject



8
9
10
11
12
13
14
# File 'lib/conify/test/api_test.rb', line 8

def base_path
  if data['api'][env].is_a?(Hash)
    URI.parse(data['api'][env]['base_url']).path
  else
    '/conflux/resources'
  end
end

#callbackObject



28
29
30
# File 'lib/conify/test/api_test.rb', line 28

def callback
  'http://localhost:7779/callback/999'
end

#conflux_idObject



16
17
18
# File 'lib/conify/test/api_test.rb', line 16

def conflux_id
  "app#{rand(10000)}@conify.goconflux.com"
end

#create_provision_payloadObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/conify/test/api_test.rb', line 32

def create_provision_payload
  payload = {
    conflux_id: conflux_id,
    plan: 'test',
    callback_url: callback,
    logplex_token: nil,
    uuid: SecureRandom.uuid
  }

  payload[:log_drain_token] = SecureRandom.hex if api_requires?('syslog_drain')

  payload
end

#credentialsObject



20
21
22
# File 'lib/conify/test/api_test.rb', line 20

def credentials
  [ data['id'], data['api']['password'] ]
end

#invalid_credsObject



24
25
26
# File 'lib/conify/test/api_test.rb', line 24

def invalid_creds
  ['wrong', 'secret']
end