summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/ldap_search
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 20:21:31 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-07 20:21:31 +0200
commit80f050080ce11c6a0cce67c9b0281c09702b00d6 (patch)
treeb486e1f6342bc757dda87df4856084f652895791 /kpov_judge/tasks/ldap_search
parent43d7ef057b4ae752a60b947e523b3a56782bf5cd (diff)
parentdbf585c2a59dbcb7f6d803d5756826b562cd7f43 (diff)
Merge branch 'fix-tasks'
Fixes pexpect usage in most tasks. Several other cleanups and minor refactoring.
Diffstat (limited to 'kpov_judge/tasks/ldap_search')
-rw-r--r--kpov_judge/tasks/ldap_search/task.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py
index 886bf07..92a7223 100644
--- a/kpov_judge/tasks/ldap_search/task.py
+++ b/kpov_judge/tasks/ldap_search/task.py
@@ -1,10 +1,8 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
+# kpov_util should be imported by add_assignment.py
-# kpov_random_helpers should be imported by add_assignment.py
# Poveži se na strežnik LDAP prek spletnega vmesnika. Ustvari uporabnika z danim imenom in geslom.
# Napiši skripto, ki izpiše podatke o tem uporabniku z ldapsearch.
-#
+
# TODO: finish this!
instructions = {
'si':"""
@@ -118,7 +116,7 @@ def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASS
s = "ldapmodify -D {BIND_DN} -w {BIND_PASSWORD} -h {LDAP_IP}".format(
**locals())
modify = pexpect.spawn(s)
- FORTUNE = kpov_random_helpers.hostname_gen(random.Random(str(LDAP_USERNAME)))
+ FORTUNE = kpov_util.hostname_gen(random.Random(str(LDAP_USERNAME)))
results['fortune'] = FORTUNE
s1 = """
dn: cn={LDAP_USERNAME},ou=Users,{FULLDOMAIN}
@@ -138,11 +136,11 @@ description: {FORTUNE}
def gen_params(user_id, params_meta):
params = dict()
r = random.Random(user_id)
- params['DOMAIN'] = kpov_random_helpers.hostname_gen(r)
- params['LDAP_USERNAME'] = kpov_random_helpers.username_gen(r)
- params['LDAP_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 6)
- params['BIND_USERNAME'] = kpov_random_helpers.username_gen(r)
- params['BIND_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 6)
+ params['DOMAIN'] = kpov_util.hostname_gen(r)
+ params['LDAP_USERNAME'] = kpov_util.username_gen(r)
+ params['LDAP_PASSWORD'] = kpov_util.alnum_gen(r, 6)
+ params['BIND_USERNAME'] = kpov_util.username_gen(r)
+ params['BIND_PASSWORD'] = kpov_util.alnum_gen(r, 6)
return params
def task_check(results, params):
@@ -164,7 +162,7 @@ objectClass: organization\r
score += 2
else:
hints += ["LDAP_USERNAME missing in: " + s + str(results['ldapsearch_before'])]
- fortune = kpov_random_helpers.hostname_gen(random.Random(str(params['LDAP_USERNAME'])))
+ fortune = kpov_util.hostname_gen(random.Random(str(params['LDAP_USERNAME'])))
s = ".*cn: {0}.*description: {1}.*".format(
re.escape(params['LDAP_USERNAME']), re.escape(fortune))
if re.match(s, results['ldapsearch_after'], re.DOTALL):