razor-client 0.16.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/NEWS.md +15 -0
  2. data/bin/razor +3 -2
  3. data/lib/razor/cli.rb +6 -0
  4. data/lib/razor/cli/command.rb +24 -13
  5. data/lib/razor/cli/navigate.rb +1 -0
  6. data/lib/razor/cli/parse.rb +29 -3
  7. data/lib/razor/cli/query.rb +2 -1
  8. data/lib/razor/cli/table_format.rb +38 -2
  9. data/lib/razor/cli/transforms.rb +8 -1
  10. data/lib/razor/cli/version.rb +1 -1
  11. data/lib/razor/cli/views.yaml +17 -4
  12. data/spec/cli/command_spec.rb +66 -0
  13. data/spec/cli/navigate_spec.rb +7 -7
  14. data/spec/cli/parse_spec.rb +23 -4
  15. data/spec/fixtures/vcr/Razor_CLI_Navigate/argument_formatting/should_allow_in_string.yml +82 -171
  16. data/spec/fixtures/vcr/Razor_CLI_Navigate/argument_formatting/should_allow_spaces.yml +281 -548
  17. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_--help_command_.yml +160 -37
  18. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_-h_command_.yml +160 -37
  19. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_command_--help_.yml +160 -37
  20. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_command_-h_.yml +160 -37
  21. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_command_help_.yml +160 -37
  22. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_command_help_for_razor_help_command_.yml +160 -37
  23. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_preserve_that_across_navigation.yml +10 -10
  24. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_supply_that_to_the_API_service.yml +5 -5
  25. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_invalid_parameter/should_fail_with_bad_JSON.yml +71 -166
  26. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_invalid_parameter/should_fail_with_malformed_argument.yml +109 -59
  27. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_array/should_merge_an_array_into_an_existing_array.yml +527 -1360
  28. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_array/should_merge_the_arguments_as_an_array.yml +528 -1361
  29. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_array/should_merge_the_arguments_into_an_existing_array.yml +528 -1361
  30. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_construct_a_json_object.yml +66 -229
  31. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_construct_a_json_object_with_unicode.yml +104 -165
  32. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_array_then_hash_.yml +57 -155
  33. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_hash_then_array_.yml +57 -220
  34. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_no_parameters/should_fail_with_bad_JSON.yml +98 -5
  35. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_append_limit.yml +8 -8
  36. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_append_start.yml +8 -8
  37. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_not_fail_when_query_returns_details_for_one_item.yml +41 -149
  38. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_store_query_without_query_parameters.yml +70 -286
  39. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_throw_an_error_if_the_query_parameter_is_not_in_the_API.yml +5 -5
  40. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_throw_an_error_if_the_query_parameter_is_not_in_the_API_from_a_single_item.yml +36 -144
  41. data/spec/fixtures/vcr/Razor_CLI_Parse/_new/_help/should_print_a_list_of_known_endpoints.yml +5 -5
  42. data/spec/spec_helper.rb +8 -4
  43. metadata +92 -85
  44. checksums.yaml +0 -7
  45. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_command_--help_.yml +0 -110
  46. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_command_help_.yml +0 -110
  47. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_help_command_.yml +0 -110
  48. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--help_--api_command_.yml +0 -110
  49. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_-a_-h_command_.yml +0 -110
  50. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_-a_command_-h_.yml +0 -110
data/NEWS.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Razor Client Release Notes
2
2
 
3
+ ## 1.0.0 - 2015-06-08
4
+
5
+ * NEW: Fit collection output to STDIN size for easier viewing.
6
+ * NEW: RAZOR_CA_FILE environment variable allows TLS/SSL certificate
7
+ verification for requests.
8
+ * NEW: The default API protocol and port are HTTPS over TLS/SSL on port 8151.
9
+ * NEW: Utilizes `aliases` property in command metadata to better guess datatypes
10
+ for aliases.
11
+ * IMPROVEMENT: `razor hooks` now displays as a table.
12
+ * IMPROVEMENT: Better output for `razor events ##`.
13
+ * IMPROVEMENT: Exits with an error code of 1 when a `razor` command fails.
14
+ * BUGFIX: `razor events` no longer causes exception.
15
+ * BUGFIX: `razor commands ## errors` no longer causes exception.
16
+ * BUGFIX: Hook output message can now be any datatype.
17
+
3
18
  ## 0.16.0 - 2015-01-05
4
19
 
5
20
  * BUGFIX: Commands were not always including authentication
data/bin/razor CHANGED
@@ -33,8 +33,9 @@ if parse.show_version?
33
33
  end
34
34
 
35
35
  if parse.show_help? and not parse.show_command_help?
36
- puts parse.help
37
- exit 0
36
+ output, exitcode = parse.help
37
+ puts output
38
+ exit exitcode
38
39
  end
39
40
 
40
41
  def unexpected_error(e)
@@ -26,6 +26,12 @@ module Razor
26
26
  end
27
27
  end
28
28
 
29
+ class InvalidCAFileError < Error
30
+ def initialize(path)
31
+ super "CA file '#{path}' in ENV variable RAZOR_CA_FILE does not exist"
32
+ end
33
+ end
34
+
29
35
  class VersionCompatibilityError < Error
30
36
  def initialize(reason)
31
37
  super "Server version is not compatible with client version: #{reason}"
@@ -37,6 +37,7 @@ class Razor::CLI::Command
37
37
  def extract_command
38
38
  cmd = command(@segments.shift)
39
39
  @cmd_url = URI.parse(cmd['id'])
40
+ @cmd_schema = cmd_schema(@cmd_url)
40
41
  body = {}
41
42
  until @segments.empty?
42
43
  argument = @segments.shift
@@ -44,7 +45,8 @@ class Razor::CLI::Command
44
45
  # `--arg=value` or `--arg value`
45
46
  arg, value = [$1, $3]
46
47
  value = @segments.shift if value.nil? && @segments[0] !~ /^--/
47
- body[arg] = convert_arg(cmd["name"], arg, value, body[arg])
48
+ arg = self.class.resolve_alias(arg, @cmd_schema)
49
+ body[arg] = self.class.convert_arg(arg, value, body[arg], @cmd_schema)
48
50
  else
49
51
  raise ArgumentError, "Unexpected argument #{argument}"
50
52
  end
@@ -63,19 +65,20 @@ class Razor::CLI::Command
63
65
  [cmd, body]
64
66
  end
65
67
 
66
- def cmd_schema(cmd_name)
68
+ def cmd_schema(cmd_url)
67
69
  begin
68
- @navigate.json_get(@cmd_url)['schema']
70
+ @navigate.json_get(cmd_url)['schema']
69
71
  rescue RestClient::ResourceNotFound => _
70
72
  raise VersionCompatibilityError, 'Server must supply the expected datatypes for command arguments; use `--json` or upgrade razor-server'
71
73
  end
72
74
  end
73
75
 
74
- def arg_type(cmd_name, arg_name)
76
+ def self.arg_type(arg_name, cmd_schema)
75
77
  # Short-circuit to allow this as a work-around for backwards compatibility.
76
78
  return nil if arg_name == 'json'
77
- cmd = cmd_schema(cmd_name)
78
- cmd && cmd[arg_name] && cmd[arg_name]['type'] or nil
79
+ return nil unless cmd_schema.is_a?(Hash)
80
+ return cmd_schema[arg_name]['type'] if cmd_schema.has_key?(arg_name)
81
+ return nil
79
82
  end
80
83
 
81
84
  # `cmd_name`: The name of the command being executed.
@@ -85,22 +88,19 @@ class Razor::CLI::Command
85
88
  # by previous calls to this method. The new `value` will be
86
89
  # concatenated to an array or hash if an array/hash is
87
90
  # accepted by the command for the given argument.
88
- def convert_arg(cmd_name, arg_name, value, existing_value)
91
+ def self.convert_arg(arg_name, value, existing_value, cmd_schema)
89
92
  value = nil if value == "null"
90
93
 
91
- argument_type = arg_type(cmd_name, arg_name)
94
+ argument_type = arg_type(arg_name, cmd_schema)
92
95
 
93
96
  # This might be helpful, since there's no other method for debug-level logging on the client.
94
- puts "Formatting argument #{arg_name} with value #{value} as #{argument_type}\n" if @parse.dump_response?
97
+ puts "Formatting argument #{arg_name} with value #{value} as #{argument_type}\n" if @parse && @parse.dump_response?
95
98
 
96
99
  case argument_type
97
100
  when "array"
98
101
  existing_value ||= []
99
102
  begin
100
- MultiJson::load(value).tap do |value|
101
- value = Array(value)
102
- existing_value + value
103
- end
103
+ existing_value + Array(MultiJson::load(value))
104
104
  rescue MultiJson::LoadError => _
105
105
  existing_value + Array(value)
106
106
  end
@@ -136,4 +136,15 @@ class Razor::CLI::Command
136
136
  raise Razor::CLI::Error, "Unexpected datatype '#{argument_type}' for argument #{arg_name}"
137
137
  end
138
138
  end
139
+
140
+ def self.resolve_alias(arg_name, cmd_schema)
141
+ return arg_name if cmd_schema[arg_name]
142
+ cmd_schema.find do |other_attr, metadata|
143
+ if metadata && metadata.has_key?('aliases')
144
+ return other_attr if metadata['aliases'].find {|aliaz| aliaz == arg_name}
145
+ end
146
+ end
147
+ # No results; return the same name to generate a reasonable error message.
148
+ arg_name
149
+ end
139
150
  end
@@ -142,6 +142,7 @@ module Razor::CLI
142
142
  def create_resource(url, headers)
143
143
  @doc_resource = RestClient::Resource.new(url.to_s, :headers => headers,
144
144
  :verify_ssl => @parse.verify_ssl?,
145
+ :ssl_ca_file => @parse.ssl_ca_file,
145
146
  :user => @username,
146
147
  :password => @password)
147
148
  end
@@ -53,14 +53,28 @@ module Razor::CLI
53
53
  end
54
54
 
55
55
  def version
56
+ begin
56
57
  <<-VERSION
57
58
  Razor Server version: #{navigate.server_version}
58
59
  Razor Client version: #{Razor::CLI::VERSION}
59
60
  VERSION
61
+ rescue RestClient::Unauthorized
62
+ puts <<-UNAUTH
63
+ Error: Credentials are required to connect to the server at #{@api_url}"
64
+ UNAUTH
65
+ exit 1
66
+ rescue
67
+ puts <<-ERR
68
+ Error: Could not connect to the server at #{@api_url}. More help is available after pointing
69
+ the client to a Razor server
70
+ ERR
71
+ exit 1
72
+ end
60
73
  end
61
74
 
62
75
  def help
63
76
  output = get_optparse.to_s
77
+ exit = 0
64
78
  begin
65
79
  output << <<-HELP
66
80
  #{list_things("Collections", navigate.collections)}
@@ -80,13 +94,15 @@ HELP
80
94
  output << <<-UNAUTH
81
95
  Error: Credentials are required to connect to the server at #{@api_url}"
82
96
  UNAUTH
97
+ exit = 1
83
98
  rescue
84
99
  output << <<-ERR
85
100
  Error: Could not connect to the server at #{@api_url}. More help is available after pointing
86
101
  the client to a Razor server
87
102
  ERR
103
+ exit = 1
88
104
  end
89
- output
105
+ [output, exit]
90
106
  end
91
107
 
92
108
  def show_version?
@@ -115,7 +131,7 @@ ERR
115
131
 
116
132
  attr_reader :api_url, :args
117
133
  # The format can be determined from later segments.
118
- attr_accessor :format, :stripped_args
134
+ attr_accessor :format, :stripped_args, :ssl_ca_file
119
135
 
120
136
  def initialize(args)
121
137
  parse_and_set_api_url(ENV["RAZOR_API"] || DEFAULT_RAZOR_API, :env)
@@ -123,8 +139,18 @@ ERR
123
139
  # To be populated externally.
124
140
  @stripped_args = []
125
141
  @format = 'short'
126
- @verify_ssl = true
142
+ # If this is set, it should actually exist.
143
+ if ENV['RAZOR_CA_FILE'] && !File.exists?(ENV['RAZOR_CA_FILE'])
144
+ raise Razor::CLI::InvalidCAFileError.new(ENV['RAZOR_CA_FILE'])
145
+ end
146
+ ca_file = ENV["RAZOR_CA_FILE"]
147
+ @ssl_ca_file = ca_file if ca_file && File.exists?(ca_file)
127
148
  @args = get_optparse.order(@args)
149
+
150
+ # Localhost won't match the server's certificate; no verification required.
151
+ # This needs to happen after get_optparse so `-k` and `-u` can take effect.
152
+ @verify_ssl ||= (@api_url.hostname != 'localhost')
153
+
128
154
  @args = set_help_vars(@args)
129
155
  if @args == ['version'] or @show_version
130
156
  @show_version = true
@@ -20,7 +20,8 @@ class Razor::CLI::Query
20
20
  query = doc.find {|coll| coll['name'] == nav}
21
21
  params = (query && query['params']) || {}
22
22
  elsif doc.is_a?(Hash)
23
- params = (doc[nav] && doc[nav]['params']) || {}
23
+ params = (doc[nav].is_a?(Hash) && doc[nav].has_key?('params') &&
24
+ doc[nav]['params'].is_a?(Hash) && doc[nav]['params']) || {}
24
25
  end
25
26
  @queryoptparse = OptionParser.new do |opts|
26
27
  opts.on "-f", "--full", "Show full details when viewing entities" do
@@ -8,7 +8,7 @@ class Razor::CLI::TableFormat
8
8
  headings = (column_overrides or get_headers(doc))
9
9
  row do
10
10
  headings.each do |header|
11
- column(header, :width => get_width(header, doc))
11
+ column(header, :width => column_width!(headings, header, doc))
12
12
  end
13
13
  end
14
14
  doc.each do |page|
@@ -23,12 +23,48 @@ class Razor::CLI::TableFormat
23
23
  capture_output.strip
24
24
  end
25
25
 
26
- def get_width(header, doc)
26
+ # This method has the side effect of modifying the remaining extra_width.
27
+ # It pulls everything together to come up with a single value for the column.
28
+ def column_width!(headings, header, doc)
29
+ content_width = content_width(header, doc)
30
+ average_width = average_width(headings)
31
+ # Is the column too wide and can we do anything about it?
32
+ if content_width > average_width && extra_width(headings, doc) > 0
33
+ # Determine how much room we'd need to make to accommodate the content.
34
+ remaining = content_width - average_width
35
+ # Add back in what we can.
36
+ width = average_width + [@extra_width, remaining].min
37
+ # The new width can't be negative.
38
+ @extra_width = [@extra_width - remaining, 0].max
39
+ width
40
+ else
41
+ [content_width, average_width].min
42
+ end
43
+ end
44
+
45
+ # This calculates how much leeway would exist in all columns if we were to
46
+ # use an auto-sized fixed width for the whole table.
47
+ def extra_width(headings, doc)
48
+ @extra_width ||= headings.map do |header|
49
+ [average_width(headings) - content_width(header, doc), 0].max
50
+ end.inject(:+)
51
+ end
52
+
53
+ # This calculates what an auto-sized fixed-width table's column width would be.
54
+ def average_width(headings)
55
+ # The 3 here = 2 for width gap + 1 for the column separator.
56
+ # The 1 is for the last separator.
57
+ @average_width ||= (((`stty size | cut -d ' ' -f 2` || 80).to_i - (headings.count * 3) - 1) / headings.count)
58
+ end
59
+
60
+ def content_width(header, doc)
61
+ # Find longest item, including the header
27
62
  (doc.map do |page|
28
63
  (page[header] or '').to_s.length
29
64
  end << header.to_s.length).max
30
65
  end
31
66
 
67
+ # Traverse all headers to compile a unique list.
32
68
  def get_headers(doc)
33
69
  [].tap do |headers|
34
70
  doc.map do |page|
@@ -33,6 +33,13 @@ module Razor::CLI
33
33
  def name_if_present(obj)
34
34
  obj ? obj['name'] : "---"
35
35
  end
36
+ def name_or_whole(obj)
37
+ if obj
38
+ (obj['name'] ? obj['name'] : obj)
39
+ else
40
+ '---'
41
+ end
42
+ end
36
43
  def count_column(hash)
37
44
  hash['count']
38
45
  end
@@ -44,7 +51,7 @@ module Razor::CLI
44
51
  end
45
52
  def event_msg(obj)
46
53
  raise Razor::CLI::HideColumnError if obj['msg'].nil?
47
- obj['msg'][0..50] + ('...' if obj['msg'].size > 50) if obj['msg']
54
+ obj['msg'].to_s[0..50] + (obj['msg'].to_s.size > 50 ? '...' : '')
48
55
  end
49
56
  def full_event_msg(obj)
50
57
  raise Razor::CLI::HideColumnError if obj['msg'].nil?
@@ -18,7 +18,7 @@ module Razor
18
18
  #
19
19
  # The next line is the one that our packaging tools modify, so please make
20
20
  # sure that any change to it is discussed and agreed first.
21
- version = '0.16.0'
21
+ version = '1.0.0'
22
22
 
23
23
  if version == "DEVELOPMENT"
24
24
  root = File.expand_path("../../..", File.dirname(__FILE__))
@@ -16,7 +16,7 @@ collections:
16
16
  +layout: table
17
17
  +show:
18
18
  name:
19
- broker-type:
19
+ broker_type:
20
20
  configuration:
21
21
  +format: nested
22
22
  policies:
@@ -26,7 +26,7 @@ collections:
26
26
  +layout: list
27
27
  +show:
28
28
  name:
29
- broker-type:
29
+ broker_type:
30
30
  configuration:
31
31
  policies:
32
32
  +format: count_column
@@ -227,8 +227,21 @@ collections:
227
227
  repo:
228
228
  +format: name_hide_nil
229
229
  command:
230
- +format: name_hide_nil
230
+ +format: name_or_whole
231
231
  task:
232
232
  +format: name_hide_nil
233
233
  entry:
234
- +format: event_misc
234
+ hooks:
235
+ +short:
236
+ +layout: table
237
+ +show:
238
+ name:
239
+ hook_type:
240
+ configuration:
241
+ +format: shallow_hash
242
+ member:
243
+ +short:
244
+ +show:
245
+ name:
246
+ hook_type:
247
+ configuration:
@@ -0,0 +1,66 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Needed to make the client work on Ruby 1.8.7
3
+ unless Kernel.respond_to?(:require_relative)
4
+ module Kernel
5
+ def require_relative(path)
6
+ require File.join(File.dirname(caller[0]), path.to_str)
7
+ end
8
+ end
9
+ end
10
+
11
+ require_relative '../spec_helper'
12
+
13
+ describe Razor::CLI::Command do
14
+ Command = Razor::CLI::Command
15
+ # let(:inst) { Class.new { include Razor::CLI::Command } }
16
+
17
+ let :existing_value do nil end
18
+
19
+ context "convert_arg" do
20
+ it "performs no conversion for 'json' reserved argument name" do
21
+ value = '/some/path'
22
+ cmd_schema = {'json' => {'type' => 'number', 'aliases' => ['b']}}
23
+ result = Command.convert_arg('json', value, existing_value, cmd_schema)
24
+ result.should == '/some/path'
25
+ end
26
+
27
+ [['number', '123', 123], ['array', '[1, 2]', [1, 2]], ['array', '1', [1]],
28
+ ['object', '{"abc":123}', {'abc' => 123}], ['object', 'abc=123', {'abc' => '123'}]].
29
+ each do |type, orig, final|
30
+ it "finds the right datatype for #{type} #{orig}" do
31
+ cmd_schema = {"tags"=>{"type"=>"#{type}"}}
32
+ result = Command.convert_arg('tags', orig, existing_value, cmd_schema)
33
+ result.should == final
34
+ end
35
+ end
36
+ it "returns argument as-is when it cannot find the datatype" do
37
+ cmd_schema = {"tags"=>{}}
38
+ result = Command.convert_arg('tags', 'abc', existing_value, cmd_schema)
39
+ result.should == 'abc'
40
+ end
41
+ it "appends to existing values" do
42
+ cmd_schema = {"tags"=>{'type' => 'array'}}
43
+ existing_value = ['abc']
44
+ result = Command.convert_arg('tags', 'def', existing_value, cmd_schema)
45
+ result.should == %w(abc def)
46
+ end
47
+ end
48
+
49
+ context "resolve_alias" do
50
+ it "resolves the alias when alias is present" do
51
+ cmd_schema = {'def' => {'type' => 'array', 'aliases' => ['abc']}}
52
+ result = Command.resolve_alias('abc', cmd_schema)
53
+ result.should == 'def'
54
+ end
55
+ it "leaves name alone when alias is present" do
56
+ cmd_schema = {'def' => {'type' => 'array', 'aliases' => ['abc']}}
57
+ result = Command.resolve_alias('ghi', cmd_schema)
58
+ result.should == 'ghi'
59
+ end
60
+ it "leaves name alone when no alias is present" do
61
+ cmd_schema = {'def' => {'type' => 'array'}}
62
+ result = Command.resolve_alias('abc', cmd_schema)
63
+ result.should == 'abc'
64
+ end
65
+ end
66
+ end
@@ -148,7 +148,7 @@ describe Razor::CLI::Navigate do
148
148
  end
149
149
 
150
150
  context "with authentication", :vcr do
151
- AuthArg = %w[-u http://fred:dead@localhost:8080/api].freeze
151
+ AuthArg = %w[-u http://fred:dead@localhost:8150/api].freeze
152
152
 
153
153
  it "should supply that to the API service" do
154
154
  nav = Razor::CLI::Parse.new(AuthArg).navigate
@@ -167,29 +167,29 @@ describe Razor::CLI::Navigate do
167
167
 
168
168
  context "with query parameters", :vcr do
169
169
  it "should append limit" do
170
- nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --limit 1]).navigate
170
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8150/api events --limit 1]).navigate
171
171
  nav.get_document.should be_an_instance_of Hash
172
172
  nav.last_url.to_s.should =~ /limit=1/
173
173
  end
174
174
  it "should append start" do
175
- nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --start 1]).navigate
175
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8150/api events --start 1]).navigate
176
176
  nav.get_document.should be_an_instance_of Hash
177
177
  nav.last_url.to_s.should =~ /start=1/
178
178
  end
179
179
  it "should throw an error if the query parameter is not in the API" do
180
- nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --not-in-api 1]).navigate
180
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8150/api events --not-in-api 1]).navigate
181
181
  expect {nav.get_document}.to raise_error(OptionParser::InvalidOption, 'invalid option: --not-in-api')
182
182
  end
183
183
  it "should not fail when query returns details for one item" do
184
184
  nav = Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:00']).navigate.get_document
185
185
  name = nav['name']
186
- nav = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name]).navigate
186
+ nav = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8150/api', 'nodes', name]).navigate
187
187
  nav.get_document['name'].should == name
188
188
  end
189
189
  it "should throw an error if the query parameter is not in the API from a single item" do
190
190
  nav = Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:00']).navigate.get_document
191
191
  name = nav['name']
192
- expect {Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name, '--limit', '1']).
192
+ expect {Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8150/api', 'nodes', name, '--limit', '1']).
193
193
  navigate.get_document}.to raise_error(OptionParser::InvalidOption, 'invalid option: --limit')
194
194
  end
195
195
  it "should store query without query parameters" do
@@ -197,7 +197,7 @@ describe Razor::CLI::Navigate do
197
197
  navigate.get_document['name']
198
198
  Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:01']).
199
199
  navigate.get_document
200
- parse = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name, 'log', '--limit', '1'])
200
+ parse = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8150/api', 'nodes', name, 'log', '--limit', '1'])
201
201
  parse.navigate.get_document
202
202
  parse.stripped_args.should == ['nodes', name, 'log']
203
203
  end