mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
commit
13b510b624
3 changed files with 25 additions and 15 deletions
|
@ -8,11 +8,11 @@ from yunohost.domain import _get_maindomain
|
|||
from yunohost.utils.error import YunohostError
|
||||
|
||||
# Get main domain
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
maindomain = ""
|
||||
|
||||
def setup_function(function):
|
||||
pass
|
||||
global maindomain
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
|
||||
def teardown_function(function):
|
||||
|
|
|
@ -11,23 +11,14 @@ from yunohost.permission import user_permission_update, user_permission_list, us
|
|||
from yunohost.domain import _get_maindomain
|
||||
|
||||
# Get main domain
|
||||
maindomain = _get_maindomain()
|
||||
maindomain = ""
|
||||
dummy_password = "test123Ynh"
|
||||
|
||||
# Dirty patch of DNS resolution. Force the DNS to 127.0.0.1 address even if dnsmasq have the public address.
|
||||
# Mainly used for 'can_access_webpage' function
|
||||
import socket
|
||||
dns_cache = {(maindomain, 443, 0, 1): [(2, 1, 6, '', ('127.0.0.1', 443))]}
|
||||
prv_getaddrinfo = socket.getaddrinfo
|
||||
def new_getaddrinfo(*args):
|
||||
try:
|
||||
return dns_cache[args]
|
||||
except KeyError:
|
||||
res = prv_getaddrinfo(*args)
|
||||
dns_cache[args] = res
|
||||
return res
|
||||
socket.getaddrinfo = new_getaddrinfo
|
||||
|
||||
prv_getaddrinfo = socket.getaddrinfo
|
||||
|
||||
def clean_user_groups_permission():
|
||||
for u in user_list()['users']:
|
||||
|
@ -40,11 +31,27 @@ def clean_user_groups_permission():
|
|||
for p in user_permission_list()['permissions']:
|
||||
if any(p.startswith(name) for name in ["wiki", "blog", "site", "permissions_app"]):
|
||||
permission_delete(p, force=True, sync_perm=False)
|
||||
socket.getaddrinfo = prv_getaddrinfo
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
clean_user_groups_permission()
|
||||
|
||||
global maindomain
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
# Dirty patch of DNS resolution. Force the DNS to 127.0.0.1 address even if dnsmasq have the public address.
|
||||
# Mainly used for 'can_access_webpage' function
|
||||
dns_cache = {(maindomain, 443, 0, 1): [(2, 1, 6, '', ('127.0.0.1', 443))]}
|
||||
def new_getaddrinfo(*args):
|
||||
try:
|
||||
return dns_cache[args]
|
||||
except KeyError:
|
||||
res = prv_getaddrinfo(*args)
|
||||
dns_cache[args] = res
|
||||
return res
|
||||
socket.getaddrinfo = new_getaddrinfo
|
||||
|
||||
user_create("alice", "Alice", "White", "alice@" + maindomain, dummy_password)
|
||||
user_create("bob", "Bob", "Snow", "bob@" + maindomain, dummy_password)
|
||||
permission_create("wiki.main", url="/", allowed=["all_users"] , sync_perm=False)
|
||||
|
|
|
@ -8,7 +8,7 @@ from yunohost.domain import _get_maindomain
|
|||
from yunohost.tests.test_permission import check_LDAP_db_integrity
|
||||
|
||||
# Get main domain
|
||||
maindomain = _get_maindomain()
|
||||
maindomain = ""
|
||||
|
||||
|
||||
def clean_user_groups():
|
||||
|
@ -23,6 +23,9 @@ def clean_user_groups():
|
|||
def setup_function(function):
|
||||
clean_user_groups()
|
||||
|
||||
global maindomain
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
user_create("alice", "Alice", "White", "alice@" + maindomain, "test123Ynh")
|
||||
user_create("bob", "Bob", "Snow", "bob@" + maindomain, "test123Ynh")
|
||||
user_create("jack", "Jack", "Black", "jack@" + maindomain, "test123Ynh")
|
||||
|
|
Loading…
Add table
Reference in a new issue