aboutsummaryrefslogtreecommitdiff
path: root/test/ejabberd_commands_test.exs
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2016-07-26 12:17:37 +0200
committerMickael Remond <mremond@process-one.net>2016-07-26 12:17:37 +0200
commit2a8005e47fdb7dbeff27dde41550221823bdb75d (patch)
tree3305d8cd8649857bb100469f285a1b4a8104c0a5 /test/ejabberd_commands_test.exs
parentClarify command module API (diff)
Add ability to run test with Elixir mix
Diffstat (limited to 'test/ejabberd_commands_test.exs')
-rw-r--r--test/ejabberd_commands_test.exs22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ejabberd_commands_test.exs b/test/ejabberd_commands_test.exs
index 31d108214..10b656140 100644
--- a/test/ejabberd_commands_test.exs
+++ b/test/ejabberd_commands_test.exs
@@ -28,7 +28,11 @@ defmodule EjabberdCommandsTest do
setup_all do
:mnesia.start
+ :stringprep.start
+ :ok = :ejabberd_config.start(["localhost"], [])
+
:ejabberd_commands.init
+ :ok
end
test "Check that we can register a command" do
@@ -37,6 +41,14 @@ defmodule EjabberdCommandsTest do
assert Enum.member?(commands, {:test_user, [], "Test user"})
end
+ test "get_exposed_commands/0 returns registered commands" do
+ commands = [open_test_command]
+ :ok = :ejabberd_commands.register_commands(commands)
+ :ok = :ejabberd_commands.expose_commands(commands)
+ exposed_commands = :ejabberd_commands.get_exposed_commands
+ assert Enum.member?(exposed_commands, :test_open)
+ end
+
test "Check that admin commands are rejected with noauth credentials" do
:ok = :ejabberd_commands.register_commands([admin_test_command])
@@ -70,6 +82,16 @@ defmodule EjabberdCommandsTest do
]}}}})
end
+ defp open_test_command do
+ ejabberd_commands(name: :test_open, tags: [:test],
+ desc: "Test open",
+ policy: :open,
+ module: __MODULE__,
+ function: :test_open,
+ args: [],
+ result: {:res, :rescode})
+ end
+
defp admin_test_command do
ejabberd_commands(name: :test_admin, tags: [:roster],
desc: "Test admin",