Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tests/support/usersupp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
#
# --- BEGIN_HEADER ---
Expand Down Expand Up @@ -27,8 +27,8 @@

"""User related details within the test support library."""

import datetime

Check failure on line 30 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'datetime' (90% confidence)

Check failure on line 30 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'datetime' (90% confidence)
import errno

Check failure on line 31 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'errno' (90% confidence)

Check failure on line 31 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'errno' (90% confidence)
import os
import pickle

Expand All @@ -37,7 +37,9 @@
from tests.support.fixturesupp import _PreparedFixture


TEST_USER_DN = '/C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=test@example.com'

Check warning on line 40 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (93 > 80 characters)

Check warning on line 40 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (93 > 80 characters)
OTHER_USER_DN = '/C=DK/ST=NA/L=NA/O=Other Org/OU=NA/CN=Other User/emailAddress=other@example.com'

Check failure on line 41 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'OTHER_USER_DN' (60% confidence)

Check warning on line 41 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (97 > 80 characters)

Check failure on line 41 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'OTHER_USER_DN' (60% confidence)

Check warning on line 41 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (97 > 80 characters)
NO_SUCH_USER_DN = '/C=DK/ST=NA/L=NA/O=No Such Org/OU=NA/CN=No Such User/emailAddress=nosuchuser@example.com'

Check failure on line 42 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'NO_SUCH_USER_DN' (60% confidence)

Check warning on line 42 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (108 > 80 characters)

Check failure on line 42 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'NO_SUCH_USER_DN' (60% confidence)

Check warning on line 42 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (108 > 80 characters)

_FIXTURE_NAME_BY_USER_DN = {
TEST_USER_DN: 'MiG-users.db--example'
Expand Down Expand Up @@ -65,7 +67,7 @@

return conf_user_db_home

@staticmethod

Check failure on line 70 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method '_provision_test_user' (60% confidence)

Check failure on line 70 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method '_provision_test_user' (60% confidence)
def _provision_test_user(testcase, distinguished_name):
"""
Fabricate a test user on demand.
Expand All @@ -91,7 +93,7 @@
# write out the user database fixture containing the user
prepared_fixture.write_to_dir(conf_user_db_home, output_format='pickle')

test_user_dir = UserAssertMixin._provision_test_user_dirs(testcase, distinguished_name)

Check warning on line 96 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (95 > 80 characters)

Check warning on line 96 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (95 > 80 characters)

return test_user_dir

Expand All @@ -112,17 +114,26 @@

# create the test user settings directory
conf_user_settings = os.path.normpath(self.configuration.user_settings)
test_user_settings_dir = os.path.join(conf_user_settings, test_client_dir_name)

Check warning on line 117 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (87 > 80 characters)

Check warning on line 117 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (87 > 80 characters)
os.makedirs(test_user_settings_dir)

# create an empty user settings file
test_user_settings_file = os.path.join(test_user_settings_dir, 'settings')

Check warning on line 121 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 121 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
with open(test_user_settings_file, 'wb') as outfile:
pickle.dump({}, outfile)

# create the test user cache, resource pending and mrsl files sub dirs
for sub in (self.configuration.user_cache,
self.configuration.resource_pending,
self.configuration.mrsl_files_dir):
conf_user_sub = os.path.normpath(sub)
test_user_sub_dir = os.path.join(
conf_user_sub, test_client_dir_name)
os.makedirs(test_user_sub_dir)

return test_user_dir

@staticmethod

Check failure on line 136 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method '_provision_test_users' (60% confidence)

Check failure on line 136 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method '_provision_test_users' (60% confidence)
def _provision_test_users(testcase, *distinguished_names):
"""
Fabricate multiple users on demand.
Expand All @@ -134,8 +145,8 @@
that the user db will be populated from arbitrary data and thus
the test dependent upon this is less strongly assured, but if
(as is the expectation) the basic operations are validated with
"indenpdent" data i.e. conained within fixtures as opposed to
generated by logic that extended tests which need
"independent" data i.e. contained within fixtures as opposed to
generated by logic that extended tests will need.
"""

conf_user_db_home = UserAssertMixin._provision_user_db_dir(testcase)
Expand All @@ -155,8 +166,8 @@
# fixture with their data but using a known fixture name and thus one
# suitably hinted so a production format pickle file ends up on-disk
prepared_fixture = _PreparedFixture(testcase, 'MiG-users.db--example')
prepared_fixture.fixture_data = users_by_dn

Check failure on line 169 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'fixture_data' (60% confidence)

Check failure on line 169 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'fixture_data' (60% confidence)
prepared_fixture.write_to_dir(conf_user_db_home, output_format='pickle')

for distinguished_name in distinguished_names:
UserAssertMixin._provision_test_user_dirs(testcase, distinguished_name)

Check warning on line 173 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)

Check warning on line 173 in tests/support/usersupp.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)
Loading