From 88cdeb0b96f07eb080eefc7a4b6988b6363512bf Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 8 Jan 2020 01:38:59 +0800 Subject: [PATCH] test auth ldap --- test/actionsmap/moulitest.yml | 14 ++++++++++++++ test/src/testauth.py | 4 ++++ test/test_auth.py | 12 ++++++++++++ test/test_ldap.py | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test/actionsmap/moulitest.yml b/test/actionsmap/moulitest.yml index b44e0ff2..5a99135f 100644 --- a/test/actionsmap/moulitest.yml +++ b/test/actionsmap/moulitest.yml @@ -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: diff --git a/test/src/testauth.py b/test/src/testauth.py index fd7e1aa9..572e13de 100644 --- a/test/src/testauth.py +++ b/test/src/testauth.py @@ -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" diff --git a/test/test_auth.py b/test/test_auth.py index e0e878be..84a66462 100644 --- a/test/test_auth.py +++ b/test/test_auth.py @@ -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): diff --git a/test/test_ldap.py b/test/test_ldap.py index 29076373..025729e8 100644 --- a/test/test_ldap.py +++ b/test/test_ldap.py @@ -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": {}, }