Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Maximilian Michal
grady
Commits
e380c42f
There was a problem fetching the pipeline summary.
Verified
Commit
e380c42f
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Plain Diff
Merge branch 'remove-dict-words-file' into convenience_test_data_method
parents
756b26c4
ce7f4674
No related branches found
No related tags found
1 merge request
!24
Added convenience method to create test data
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+0
-3
0 additions, 3 deletions
Dockerfile
util/factories.py
+7
-8
7 additions, 8 deletions
util/factories.py
with
7 additions
and
11 deletions
Dockerfile
+
0
−
3
View file @
e380c42f
...
@@ -17,9 +17,6 @@ RUN apk update \
...
@@ -17,9 +17,6 @@ RUN apk update \
&&
apk add
--virtual
build-deps gcc python3-dev musl-dev curl
\
&&
apk add
--virtual
build-deps gcc python3-dev musl-dev curl
\
&&
apk add
--no-cache
postgresql-dev
&&
apk add
--no-cache
postgresql-dev
RUN
mkdir
-p
/usr/share/dict
RUN
curl
-s
https://gitlab.gwdg.de/snippets/51/raw
--output
/usr/share/dict/words
WORKDIR
/code
WORKDIR
/code
COPY
. /code
COPY
. /code
...
...
This diff is collapsed.
Click to expand it.
util/factories.py
+
7
−
8
View file @
e380c42f
import
configparser
import
configparser
import
secrets
import
secrets
import
string
from
core.models
import
UserAccount
as
User
from
core.models
import
UserAccount
as
User
from
core.models
import
Reviewer
,
Student
,
Tutor
from
core.models
import
Reviewer
,
Student
,
Tutor
...
@@ -11,12 +12,10 @@ REVIEWERS = 'reviewers'
...
@@ -11,12 +12,10 @@ REVIEWERS = 'reviewers'
PASSWORDS
=
'
.importer_passwords
'
PASSWORDS
=
'
.importer_passwords
'
def
get_xkcd_password
(
k
=
2
):
def
get_random_password
(
length
=
32
):
with
open
(
'
/usr/share/dict/words
'
)
as
words
:
"""
Returns a cryptographically random string of specified length
"""
choose_from
=
list
({
word
.
strip
().
lower
()
return
''
.
join
(
secrets
.
choice
(
string
.
ascii_lowercase
)
for
word
in
words
if
5
<
len
(
word
)
<
8
})
for
_
in
range
(
length
))
return
''
.
join
(
secrets
.
choice
(
choose_from
)
for
_
in
range
(
k
))
def
store_password
(
username
,
groupname
,
password
):
def
store_password
(
username
,
groupname
,
password
):
...
@@ -35,7 +34,7 @@ def store_password(username, groupname, password):
...
@@ -35,7 +34,7 @@ def store_password(username, groupname, password):
class
GradyUserFactory
:
class
GradyUserFactory
:
def
__init__
(
self
,
def
__init__
(
self
,
password_generator_func
=
get_
xkcd
_password
,
password_generator_func
=
get_
random
_password
,
password_storge
=
store_password
,
password_storge
=
store_password
,
*
args
,
**
kwargs
):
*
args
,
**
kwargs
):
self
.
password_generator_func
=
password_generator_func
self
.
password_generator_func
=
password_generator_func
...
@@ -43,7 +42,7 @@ class GradyUserFactory:
...
@@ -43,7 +42,7 @@ class GradyUserFactory:
@staticmethod
@staticmethod
def
_get_random_name
(
prefix
=
''
,
suffix
=
''
,
k
=
1
):
def
_get_random_name
(
prefix
=
''
,
suffix
=
''
,
k
=
1
):
return
''
.
join
((
prefix
,
get_
xkcd
_password
(
k
),
suffix
))
return
''
.
join
((
prefix
,
get_
random
_password
(
k
),
suffix
))
def
_make_base_user
(
self
,
username
,
groupname
,
store_pw
=
False
,
**
kwargs
):
def
_make_base_user
(
self
,
username
,
groupname
,
store_pw
=
False
,
**
kwargs
):
"""
This is a specific wrapper for the django update_or_create method of
"""
This is a specific wrapper for the django update_or_create method of
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment