-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: pass config to constructor instead of configuring after
- Loading branch information
1 parent
5ba6aa1
commit 4cf07bc
Showing
2 changed files
with
68 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from ..ldapauthenticator import LDAPAuthenticator | ||
from traitlets.config import Config | ||
|
||
|
||
@pytest.fixture() | ||
def authenticator(): | ||
authenticator = LDAPAuthenticator() | ||
authenticator.server_address = os.environ.get("LDAP_HOST", "localhost") | ||
authenticator.lookup_dn = True | ||
authenticator.bind_dn_template = "cn={username},ou=people,dc=planetexpress,dc=com" | ||
authenticator.user_search_base = "ou=people,dc=planetexpress,dc=com" | ||
authenticator.user_attribute = "uid" | ||
authenticator.lookup_dn_user_dn_attribute = "cn" | ||
authenticator.attributes = ["uid", "cn", "mail", "ou"] | ||
authenticator.use_lookup_dn_username = False | ||
def c(): | ||
""" | ||
A base configuration for LDAPAuthenticator that individual tests can adjust. | ||
""" | ||
c = Config() | ||
c.LDAPAuthenticator.server_address = os.environ.get("LDAP_HOST", "localhost") | ||
c.LDAPAuthenticator.lookup_dn = True | ||
c.LDAPAuthenticator.bind_dn_template = ( | ||
"cn={username},ou=people,dc=planetexpress,dc=com" | ||
) | ||
c.LDAPAuthenticator.user_search_base = "ou=people,dc=planetexpress,dc=com" | ||
c.LDAPAuthenticator.user_attribute = "uid" | ||
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = "cn" | ||
c.LDAPAuthenticator.attributes = ["uid", "cn", "mail", "ou"] | ||
c.LDAPAuthenticator.use_lookup_dn_username = False | ||
|
||
authenticator.allowed_groups = [ | ||
c.LDAPAuthenticator.allowed_groups = [ | ||
"cn=admin_staff,ou=people,dc=planetexpress,dc=com", | ||
"cn=ship_crew,ou=people,dc=planetexpress,dc=com", | ||
] | ||
|
||
return authenticator | ||
return c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters