mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fix elixir tests
This commit is contained in:
parent
c64e77a08c
commit
e790e66f47
@ -363,70 +363,10 @@ defmodule ACLTest do
|
||||
assert :acl.access_rules_validator(:my_access) == :my_access
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation works with <AccessName>" do
|
||||
assert :gen_mod.get_opt(:access, [access: :my_rule], &:acl.access_rules_validator/1)
|
||||
== :my_rule
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation perform normalization for acl rules" do
|
||||
assert :gen_mod.get_opt(:access, [access: [[allow: :zed]]], &:acl.access_rules_validator/1)
|
||||
== [allow: [acl: :zed]]
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation perform normalization for user@server rules" do
|
||||
assert :gen_mod.get_opt(:access, [access: [allow: [user: "a@b"]]], &:acl.access_rules_validator/1)
|
||||
== [allow: [user: {"a", "b"}]]
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation return default value with number as rule type" do
|
||||
assert :gen_mod.get_opt(:access, [access: [{100, [user: "a@b"]}]], &:acl.access_rules_validator/1)
|
||||
== :undefined
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation return default value when invalid rule type is passed" do
|
||||
assert :gen_mod.get_opt(:access, [access: [allow2: [user: "a@b"]]], &:acl.access_rules_validator/1)
|
||||
== :undefined
|
||||
end
|
||||
|
||||
test "get_opt with access_rules_validation return default value when invalid acl is passed" do
|
||||
assert :gen_mod.get_opt(:access, [access: [allow: [user2: "a@b"]]], &:acl.access_rules_validator/1)
|
||||
== :undefined
|
||||
end
|
||||
|
||||
test "shapes_rules_validator works with <AccessName>" do
|
||||
assert :acl.shaper_rules_validator(:my_access) == :my_access
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation works with <AccessName>" do
|
||||
assert :gen_mod.get_opt(:access, [access: :my_rule], &:acl.shaper_rules_validator/1)
|
||||
== :my_rule
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation perform normalization for acl rules" do
|
||||
assert :gen_mod.get_opt(:access, [access: [[allow: :zed]]], &:acl.shaper_rules_validator/1)
|
||||
== [allow: [acl: :zed]]
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation perform normalization for user@server rules" do
|
||||
assert :gen_mod.get_opt(:access, [access: [allow: [user: "a@b"]]], &:acl.shaper_rules_validator/1)
|
||||
== [allow: [user: {"a", "b"}]]
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation return accepts number as rule type" do
|
||||
assert :gen_mod.get_opt(:access, [access: [{100, [user: "a@b"]}]], &:acl.shaper_rules_validator/1)
|
||||
== [{100, [user: {"a", "b"}]}]
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation return accepts any atom as rule type" do
|
||||
assert :gen_mod.get_opt(:access, [access: [fast: [user: "a@b"]]], &:acl.shaper_rules_validator/1)
|
||||
== [fast: [user: {"a", "b"}]]
|
||||
end
|
||||
|
||||
test "get_opt with shaper_rules_validation return default value when invalid acl is passed" do
|
||||
assert :gen_mod.get_opt(:access, [access: [allow: [user2: "a@b"]]], &:acl.shaper_rules_validator/1)
|
||||
== :undefined
|
||||
end
|
||||
|
||||
## Checking ACL on both user pattern and IP
|
||||
## ========================================
|
||||
|
||||
|
@ -42,7 +42,7 @@ defmodule EjabberdCommandsMockTest do
|
||||
Record.defrecord :ejabberd_commands, Record.extract(:ejabberd_commands, from_lib: "ejabberd/include/ejabberd_commands.hrl")
|
||||
|
||||
setup_all do
|
||||
:ok = :ejabberd.start_app(:lager)
|
||||
:ok = :ejabberd.start_app(:lager)
|
||||
try do
|
||||
:stringprep.start
|
||||
rescue
|
||||
@ -50,14 +50,15 @@ defmodule EjabberdCommandsMockTest do
|
||||
end
|
||||
:mnesia.start
|
||||
:ejabberd_mnesia.start
|
||||
:jid.start
|
||||
:ejabberd_hooks.start_link
|
||||
:ok = :ejabberd_config.start(["domain1", "domain2"], [])
|
||||
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||
{:ok, _} = :acl.start_link
|
||||
:jid.start
|
||||
:ejabberd_hooks.start_link
|
||||
:ok = :ejabberd_config.start(["domain1", "domain2"], [])
|
||||
{:ok, _} = :ejabberd_access_permissions.start_link()
|
||||
{:ok, _} = :acl.start_link
|
||||
:ejabberd_oauth.start_link
|
||||
:ejabberd_commands.start_link
|
||||
EjabberdOauthMock.init
|
||||
on_exit fn -> :meck.unload end
|
||||
on_exit fn -> :meck.unload end
|
||||
end
|
||||
|
||||
setup do
|
||||
@ -453,13 +454,17 @@ defmodule EjabberdCommandsMockTest do
|
||||
|
||||
:meck.new :ejabberd_config
|
||||
:meck.expect(:ejabberd_config, :get_option,
|
||||
fn(:commands_admin_access, _, _) -> :commands_admin_access
|
||||
(:oauth_access, _, _) -> :all
|
||||
(:commands, _, _) -> [{:add_commands, commands}]
|
||||
(_, _, default) -> default
|
||||
fn(:commands_admin_access, _) -> :commands_admin_access
|
||||
(:oauth_access, _) -> :all
|
||||
(:commands, _) -> [{:add_commands, commands}]
|
||||
(_, default) -> default
|
||||
end)
|
||||
:meck.expect(:ejabberd_config, :get_myhosts,
|
||||
fn() -> [@domain] end)
|
||||
:meck.expect(:ejabberd_config, :default_db,
|
||||
fn(_) -> :mnesia end)
|
||||
:meck.expect(:ejabberd_config, :default_db,
|
||||
fn(_, _) -> :mnesia end)
|
||||
|
||||
:meck.new :acl
|
||||
:meck.expect(:acl, :access_matches,
|
||||
|
Loading…
Reference in New Issue
Block a user