test auth ldap

This commit is contained in:
Kay0u 2020-01-08 01:38:59 +08:00
parent 142081a934
commit 88cdeb0b96
No known key found for this signature in database
GPG key ID: 7FF262C033518333
4 changed files with 31 additions and 1 deletions

View file

@ -13,6 +13,13 @@ _global:
yoloswag:
vendor: dummy
help: Dummy Yoloswag Password
ldap:
vendor: ldap
help: admin_password
parameters:
uri: ldap://localhost:8080
base_dn: dc=yunohost,dc=org
user_rdn: cn=admin,dc=yunohost,dc=org
arguments:
-v:
full: --version
@ -54,6 +61,13 @@ testauth:
- all
authenticator: yoloswag
ldap:
api: GET /test-auth/ldap
configuration:
authenticate:
- all
authenticator: ldap
subcategories:
subcat:
actions:

View file

@ -32,3 +32,7 @@ def testauth_only_api():
def testauth_only_cli():
return "some_data_from_only_cli"
def testauth_ldap():
return "some_data_from_ldap"

View file

@ -158,6 +158,18 @@ class TestAuthAPI:
== "Authentication required"
)
def test_login_ldap(self, moulinette_webapi, ldap_server, mocker):
mocker.patch(
"moulinette.authenticators.ldap.Authenticator._get_uri",
return_value=ldap_server.uri,
)
self.login(moulinette_webapi, profile="ldap", password="yunohost")
assert (
moulinette_webapi.get("/test-auth/ldap", status=200).text
== '"some_data_from_ldap"'
)
class TestAuthCLI:
def test_login(self, moulinette_cli, capsys, mocker):

View file

@ -11,7 +11,7 @@ class TestLDAP:
self.ldap_conf = {
"vendor": "ldap",
"name": "as-root",
"parameters": {"base_dn": "dc=yunohost,dc=org",},
"parameters": {"base_dn": "dc=yunohost,dc=org"},
"extra": {},
}