mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
test:domains: dyndns_recovery mock as api call to avoid cli prompts
This commit is contained in:
parent
c019f7f24a
commit
253a042314
1 changed files with 25 additions and 20 deletions
|
@ -1,8 +1,10 @@
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
import time
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from mock import patch
|
||||||
|
|
||||||
|
from moulinette import Moulinette
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
|
@ -87,25 +89,28 @@ def test_domain_add_and_remove_dyndns():
|
||||||
def test_domain_dyndns_recovery():
|
def test_domain_dyndns_recovery():
|
||||||
# Devs: if you get `too_many_request` errors, ask the team to add your IP to the rate limit excempt
|
# Devs: if you get `too_many_request` errors, ask the team to add your IP to the rate limit excempt
|
||||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||||
# add domain without recovery password
|
# mocked as API call to avoid CLI prompts
|
||||||
domain_add(TEST_DYNDNS_DOMAIN)
|
with patch.object(Moulinette.interface, "type", "api"):
|
||||||
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
# add domain without recovery password
|
||||||
# set the recovery password with config panel
|
domain_add(TEST_DYNDNS_DOMAIN)
|
||||||
domain_config_set(TEST_DYNDNS_DOMAIN, "dns.registrar.recovery_password", TEST_DYNDNS_PASSWORD)
|
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
||||||
# remove domain without unsubscribing
|
# set the recovery password with config panel
|
||||||
domain_remove(TEST_DYNDNS_DOMAIN, ignore_dyndns=True)
|
domain_config_set(TEST_DYNDNS_DOMAIN, "dns.registrar.recovery_password", TEST_DYNDNS_PASSWORD)
|
||||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
# remove domain without unsubscribing
|
||||||
# readding domain with bad password should fail
|
domain_remove(TEST_DYNDNS_DOMAIN, ignore_dyndns=True)
|
||||||
with pytest.raises(YunohostValidationError):
|
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||||
domain_add(
|
# readding domain with bad password should fail
|
||||||
TEST_DYNDNS_DOMAIN, dyndns_recovery_password="wrong" + TEST_DYNDNS_PASSWORD
|
with pytest.raises(YunohostValidationError):
|
||||||
)
|
domain_add(
|
||||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
TEST_DYNDNS_DOMAIN, dyndns_recovery_password="wrong" + TEST_DYNDNS_PASSWORD
|
||||||
# readding domain with password should work
|
)
|
||||||
domain_add(TEST_DYNDNS_DOMAIN, dyndns_recovery_password=TEST_DYNDNS_PASSWORD)
|
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||||
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
# readding domain with password should work
|
||||||
# remove the dyndns domain
|
domain_add(TEST_DYNDNS_DOMAIN, dyndns_recovery_password=TEST_DYNDNS_PASSWORD)
|
||||||
domain_remove(TEST_DYNDNS_DOMAIN, dyndns_recovery_password=TEST_DYNDNS_PASSWORD)
|
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
||||||
|
# remove the dyndns domain
|
||||||
|
domain_remove(TEST_DYNDNS_DOMAIN, dyndns_recovery_password=TEST_DYNDNS_PASSWORD)
|
||||||
|
|
||||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue