mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Initialize ejabberd_access_permissions in elixir tests
This commit is contained in:
parent
98e0123ca4
commit
695d22ef95
@ -28,6 +28,7 @@ defmodule EjabberdAdminTest do
|
|||||||
# For some myterious reason, :ejabberd_commands.init mays
|
# For some myterious reason, :ejabberd_commands.init mays
|
||||||
# sometimes fails if module is not loaded before
|
# sometimes fails if module is not loaded before
|
||||||
{:module, :ejabberd_commands} = Code.ensure_loaded(:ejabberd_commands)
|
{:module, :ejabberd_commands} = Code.ensure_loaded(:ejabberd_commands)
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
:ejabberd_commands.init
|
:ejabberd_commands.init
|
||||||
:ejabberd_admin.start
|
:ejabberd_admin.start
|
||||||
:ok
|
:ok
|
||||||
|
@ -50,6 +50,7 @@ defmodule EjabberdCommandsMockTest do
|
|||||||
:mnesia.start
|
:mnesia.start
|
||||||
:ok = :jid.start
|
:ok = :jid.start
|
||||||
:ok = :ejabberd_config.start(["domain1", "domain2"], [])
|
:ok = :ejabberd_config.start(["domain1", "domain2"], [])
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
:ok = :acl.start
|
:ok = :acl.start
|
||||||
EjabberdOauthMock.init
|
EjabberdOauthMock.init
|
||||||
on_exit fn -> :meck.unload end
|
on_exit fn -> :meck.unload end
|
||||||
|
@ -30,6 +30,7 @@ defmodule EjabberdCommandsTest do
|
|||||||
:mnesia.start
|
:mnesia.start
|
||||||
:stringprep.start
|
:stringprep.start
|
||||||
:ok = :ejabberd_config.start(["localhost"], [])
|
:ok = :ejabberd_config.start(["localhost"], [])
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
|
|
||||||
:ejabberd_commands.init
|
:ejabberd_commands.init
|
||||||
:ok
|
:ok
|
||||||
|
@ -45,6 +45,7 @@ defmodule EjabberdModAdminExtraTest do
|
|||||||
rescue
|
rescue
|
||||||
_ -> :ok
|
_ -> :ok
|
||||||
end
|
end
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
:ejabberd_commands.init
|
:ejabberd_commands.init
|
||||||
:ok = :ejabberd_config.start([@domain], [])
|
:ok = :ejabberd_config.start([@domain], [])
|
||||||
:mod_admin_extra.start(@domain, [])
|
:mod_admin_extra.start(@domain, [])
|
||||||
|
@ -46,6 +46,7 @@ defmodule ModHttpApiMockTest do
|
|||||||
:mnesia.start
|
:mnesia.start
|
||||||
:stringprep.start
|
:stringprep.start
|
||||||
:ejabberd_config.start([@domain], [])
|
:ejabberd_config.start([@domain], [])
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
:ejabberd_commands.init
|
:ejabberd_commands.init
|
||||||
rescue
|
rescue
|
||||||
_ -> :ok
|
_ -> :ok
|
||||||
@ -240,10 +241,10 @@ defmodule ModHttpApiMockTest do
|
|||||||
result = :ejabberd_oauth.process([], req)
|
result = :ejabberd_oauth.process([], req)
|
||||||
assert 200 = elem(result, 0) #http code
|
assert 200 = elem(result, 0) #http code
|
||||||
{kv} = :jiffy.decode(elem(result,2))
|
{kv} = :jiffy.decode(elem(result,2))
|
||||||
assert {_, "bearer"} = List.keyfind(kv, "token_type", 0)
|
assert {_, "bearer"} = List.keyfind(kv, "token_type", 0)
|
||||||
assert {_, @command} = List.keyfind(kv, "scope", 0)
|
assert {_, @command} = List.keyfind(kv, "scope", 0)
|
||||||
assert {_, 4000} = List.keyfind(kv, "expires_in", 0)
|
assert {_, 4000} = List.keyfind(kv, "expires_in", 0)
|
||||||
{"access_token", _token} = List.keyfind(kv, "access_token", 0)
|
{"access_token", _token} = List.keyfind(kv, "access_token", 0)
|
||||||
|
|
||||||
#missing grant_type
|
#missing grant_type
|
||||||
req = request(method: :POST,
|
req = request(method: :POST,
|
||||||
@ -254,7 +255,7 @@ defmodule ModHttpApiMockTest do
|
|||||||
result = :ejabberd_oauth.process([], req)
|
result = :ejabberd_oauth.process([], req)
|
||||||
assert 400 = elem(result, 0) #http code
|
assert 400 = elem(result, 0) #http code
|
||||||
{kv} = :jiffy.decode(elem(result,2))
|
{kv} = :jiffy.decode(elem(result,2))
|
||||||
assert {_, "unsupported_grant_type"} = List.keyfind(kv, "error", 0)
|
assert {_, "unsupported_grant_type"} = List.keyfind(kv, "error", 0)
|
||||||
|
|
||||||
|
|
||||||
# incorrect user/pass
|
# incorrect user/pass
|
||||||
@ -266,7 +267,7 @@ defmodule ModHttpApiMockTest do
|
|||||||
result = :ejabberd_oauth.process([], req)
|
result = :ejabberd_oauth.process([], req)
|
||||||
assert 400 = elem(result, 0) #http code
|
assert 400 = elem(result, 0) #http code
|
||||||
{kv} = :jiffy.decode(elem(result,2))
|
{kv} = :jiffy.decode(elem(result,2))
|
||||||
assert {_, "invalid_grant"} = List.keyfind(kv, "error", 0)
|
assert {_, "invalid_grant"} = List.keyfind(kv, "error", 0)
|
||||||
|
|
||||||
assert :meck.validate :ejabberd_auth
|
assert :meck.validate :ejabberd_auth
|
||||||
assert :meck.validate :ejabberd_commands
|
assert :meck.validate :ejabberd_commands
|
||||||
|
@ -31,6 +31,7 @@ defmodule ModHttpApiTest do
|
|||||||
:ok = :mnesia.start
|
:ok = :mnesia.start
|
||||||
:stringprep.start
|
:stringprep.start
|
||||||
:ok = :ejabberd_config.start(["localhost"], [])
|
:ok = :ejabberd_config.start(["localhost"], [])
|
||||||
|
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||||
:ok = :ejabberd_commands.init
|
:ok = :ejabberd_commands.init
|
||||||
:ok = :ejabberd_commands.register_commands(cmds)
|
:ok = :ejabberd_commands.register_commands(cmds)
|
||||||
on_exit fn ->
|
on_exit fn ->
|
||||||
|
Loading…
Reference in New Issue
Block a user