Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Hsin-Yu Chien
edx-platform-release
Commits
9eb1cce3
Commit
9eb1cce3
authored
11 years ago
by
ihoover
Browse files
Options
Downloads
Patches
Plain Diff
maximum number of random users
parent
66eb47fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/djangoapps/student/views.py
+25
-0
25 additions, 0 deletions
common/djangoapps/student/views.py
lms/djangoapps/branding/views.py
+24
-6
24 additions, 6 deletions
lms/djangoapps/branding/views.py
lms/envs/common.py
+3
-2
3 additions, 2 deletions
lms/envs/common.py
with
52 additions
and
8 deletions
common/djangoapps/student/views.py
+
25
−
0
View file @
9eb1cce3
...
...
@@ -918,6 +918,21 @@ def get_random_post_override():
'
honor_code
'
:
u
'
true
'
,
'
terms_of_service
'
:
u
'
true
'
,
}
def
get_planned_post_override
(
username
,
password
):
"""
Return a dictionary suitable for passing to post_vars of _do_create_account or post_override
of create_account, with specified username and password.
"""
def
id_generator
(
size
=
6
,
chars
=
string
.
ascii_uppercase
+
string
.
ascii_lowercase
+
string
.
digits
):
return
''
.
join
(
random
.
choice
(
chars
)
for
x
in
range
(
size
))
return
{
'
username
'
:
username
,
'
email
'
:
id_generator
(
size
=
10
,
chars
=
string
.
ascii_lowercase
)
+
"
_dummy_test@mitx.mit.edu
"
,
'
password
'
:
password
,
'
name
'
:
(
id_generator
(
size
=
5
,
chars
=
string
.
ascii_lowercase
)
+
"
"
+
id_generator
(
size
=
7
,
chars
=
string
.
ascii_lowercase
)),
'
honor_code
'
:
u
'
true
'
,
'
terms_of_service
'
:
u
'
true
'
,
}
def
create_random_account
(
create_account_function
):
def
inner_create_random_account
(
request
):
...
...
@@ -929,6 +944,16 @@ def create_random_account(create_account_function):
if
settings
.
GENERATE_RANDOM_USER_CREDENTIALS
:
create_account
=
create_random_account
(
create_account
)
def
create_random_account_with_name_and_password
(
create_account_function
):
def
inner_create_random_account
(
request
,
username
,
password
):
return
create_account_function
(
request
,
post_override
=
get_planned_post_override
(
username
,
password
))
return
inner_create_random_account
# for load testing we want to create lots of accounts
# with controlled username and password
if
settings
.
AUTOMATIC_AUTH_FOR_LOAD_TESTING
:
create_account
=
create_random_account_with_name_and_password
(
create_account
)
@ensure_csrf_cookie
def
activate_account
(
request
,
key
):
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/branding/views.py
+
24
−
6
View file @
9eb1cce3
...
...
@@ -58,12 +58,30 @@ def auto_auth(request):
true.
"""
# log the user in
student
.
views
.
create_account
(
request
)
# activate account
request
.
user
.
is_active
=
True
request
.
user
.
save
()
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
login
,
authenticate
from
random
import
randint
# generate random user ceredentials from a small name space
name_base
=
'
USER_
'
pass_base
=
'
PASS_
'
number
=
randint
(
1
,
settings
.
MAX_AUTO_AUTH_USERS
)
username
=
name_base
+
str
(
number
)
password
=
pass_base
+
str
(
number
)
# if they already are a user, log in
try
:
user
=
User
.
objects
.
get
(
username
=
username
)
user
=
authenticate
(
username
=
username
,
password
=
password
)
login
(
request
,
user
)
except
:
# create and activate account info
student
.
views
.
create_account
(
request
,
username
,
password
)
request
.
user
.
is_active
=
True
request
.
user
.
save
()
# redirect to home-page
return
redirect
(
'
root
'
)
This diff is collapsed.
Click to expand it.
lms/envs/common.py
+
3
−
2
View file @
9eb1cce3
...
...
@@ -38,12 +38,13 @@ COURSEWARE_ENABLED = True
ENABLE_JASMINE
=
False
AUTOMATIC_AUTH_FOR_LOAD_TESTING
=
True
MAX_AUTO_AUTH_USERS
=
2
GENERATE_RANDOM_USER_CREDENTIALS
=
False
PERFSTATS
=
False
# automatic_auth should turn on random_cred of it needs to
GENERATE_RANDOM_USER_CREDENTIALS
=
GENERATE_RANDOM_USER_CREDENTIALS
or
AUTOMATIC_AUTH_FOR_LOAD_TESTING
#
# automatic_auth should turn on random_cred of it needs to
#
GENERATE_RANDOM_USER_CREDENTIALS = GENERATE_RANDOM_USER_CREDENTIALS or AUTOMATIC_AUTH_FOR_LOAD_TESTING
DISCUSSION_SETTINGS
=
{
'
MAX_COMMENT_DEPTH
'
:
2
,
...
...
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