summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_cli/test/diagnostics
diff options
context:
space:
mode:
authorDaniil Fedotov <hairyhum@gmail.com>2019-04-24 15:33:04 -0400
committerDaniil Fedotov <hairyhum@gmail.com>2019-04-24 15:37:28 -0400
commitb53a16681a6dba0c5607202b41b218a8cf7f61eb (patch)
tree7bd2f00d1b991ecc9e900d507f34709944b40115 /deps/rabbitmq_cli/test/diagnostics
parent6c8719bca21685d66dafbc06908b33da6fe12762 (diff)
downloadrabbitmq-server-git-b53a16681a6dba0c5607202b41b218a8cf7f61eb.tar.gz
Add more flags to cipher_suites command to return all available suites and more formats.
Support new map format for cipher suites added in OTP-20.3 Support --all flag to get all available ciphers Addresses #342 Depends on changes in rabbitmq-server
Diffstat (limited to 'deps/rabbitmq_cli/test/diagnostics')
-rw-r--r--deps/rabbitmq_cli/test/diagnostics/cipher_suites_command_test.exs59
1 files changed, 44 insertions, 15 deletions
diff --git a/deps/rabbitmq_cli/test/diagnostics/cipher_suites_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/cipher_suites_command_test.exs
index 22f9462284..662ba0071a 100644
--- a/deps/rabbitmq_cli/test/diagnostics/cipher_suites_command_test.exs
+++ b/deps/rabbitmq_cli/test/diagnostics/cipher_suites_command_test.exs
@@ -30,8 +30,10 @@ defmodule CipherSuitesCommandTest do
{:ok, opts: %{
node: get_rabbit_hostname(),
timeout: context[:test_timeout] || 30000,
- openssl_format: context[:openssl_format] || true,
- erlang_format: context[:erlang_format] || false
+ openssl_format: true,
+ erlang_format: false,
+ map_format: false,
+ all: false
}}
end
@@ -40,11 +42,11 @@ defmodule CipherSuitesCommandTest do
end
test "validate: providing --openssl-format passes validation", context do
- assert @command.validate([], Map.merge(%{openssl_format: true}, context[:opts])) == :ok
+ assert @command.validate([], Map.merge(context[:opts], %{openssl_format: true})) == :ok
end
test "validate: providing --erlang-format passes validation", context do
- assert @command.validate([], Map.merge(%{erlang_format: true}, context[:opts])) == :ok
+ assert @command.validate([], Map.merge(context[:opts], %{erlang_format: true, openssl_format: false})) == :ok
end
test "validate: providing any arguments fails validation", context do
@@ -52,21 +54,25 @@ defmodule CipherSuitesCommandTest do
{:validation_failure, :too_many_args}
end
- test "validate: setting both --openssl-format and --erlang-format to false fails validation", context do
- assert @command.validate([], Map.merge(context[:opts], %{openssl_format: false, erlang_format: false})) ==
- {:validation_failure, {:bad_argument, "Either OpenSSL or Erlang term format must be selected"}}
+ test "validate: setting all formats to false fails validation", context do
+ assert @command.validate([], Map.merge(context[:opts],
+ %{openssl_format: false,
+ erlang_format: false,
+ map_format: false})) ==
+ {:validation_failure, {:bad_argument, "At least one format must be selected"}}
end
test "validate: setting both --openssl-format and --erlang-format to true fails validation", context do
assert @command.validate([], Map.merge(context[:opts], %{openssl_format: true, erlang_format: true})) ==
- {:validation_failure, {:bad_argument, "Cannot use both formats together"}}
+ {:validation_failure, {:bad_argument, "Cannot use multiple formats together"}}
end
test "validate: treats empty positional arguments and default switches as a success" do
- assert @command.validate([], %{openssl_format: true, erlang_format: false}) == :ok
+ assert @command.validate([], %{openssl_format: true,
+ erlang_format: false}) == :ok
end
- test "validate: treats empty positional arguments and an Erlang term format flag as a success" do
+ test "validate: treats empty positional arguments Erlang term format flag and default flag as a success" do
assert @command.validate([], %{erlang_format: true}) == :ok
end
@@ -75,17 +81,40 @@ defmodule CipherSuitesCommandTest do
assert match?({:badrpc, _}, @command.run([], Map.merge(context[:opts], %{node: :jake@thedog})))
end
- test "run: returns a list of cipher suites", context do
+ test "run: returns a list of cipher suites in OpenSSL format", context do
res = @command.run([], context[:opts])
+ for cipher <- res, do: assert true == is_list(cipher)
# the list is long and its values are environment-specific,
# so we simply assert that it is non-empty. MK.
assert length(res) > 0
end
- @tag openssl_format: true
- test "run: returns a list cipher suites in the OpenSSL format", context do
- res = @command.run([], context[:opts])
- # see the test above
+ test "run: returns a list of cipher suites in erlang format", context do
+ res = @command.run([], Map.merge(context[:opts], %{openssl_format: false,
+ erlang_format: true}))
+
+ for cipher <- res, do: assert true = is_tuple(cipher)
+ # the list is long and its values are environment-specific,
+ # so we simply assert that it is non-empty. MK.
+ assert length(res) > 0
+ end
+
+ test "run: returns a list of cipher suites in map format", context do
+ res = @command.run([], Map.merge(context[:opts], %{openssl_format: false,
+ map_format: true}))
+ for cipher <- res, do: assert true = is_map(cipher)
+ # the list is long and its values are environment-specific,
+ # so we simply assert that it is non-empty. MK.
assert length(res) > 0
end
+
+ test "run: returns more cipher suites when all suites requested", context do
+ all_suites_opts = Map.merge(context[:opts], %{all: true})
+ default_suites_opts = Map.merge(context[:opts], %{all: false})
+ all_suites = @command.run([], all_suites_opts)
+ default_suites = @command.run([], default_suites_opts)
+ assert length(all_suites) > length(default_suites)
+ assert length(default_suites -- all_suites) == 0
+ end
+
end