Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
9eb1cce3
Commit
9eb1cce3
authored
Jul 16, 2013
by
ihoover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maximum number of random users
parent
66eb47fb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
8 deletions
+52
-8
common/djangoapps/student/views.py
+25
-0
lms/djangoapps/branding/views.py
+24
-6
lms/envs/common.py
+3
-2
No files found.
common/djangoapps/student/views.py
View file @
9eb1cce3
...
@@ -918,6 +918,21 @@ def get_random_post_override():
...
@@ -918,6 +918,21 @@ def get_random_post_override():
'honor_code'
:
u'true'
,
'honor_code'
:
u'true'
,
'terms_of_service'
:
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
create_random_account
(
create_account_function
):
def
inner_create_random_account
(
request
):
def
inner_create_random_account
(
request
):
...
@@ -929,6 +944,16 @@ def create_random_account(create_account_function):
...
@@ -929,6 +944,16 @@ def create_random_account(create_account_function):
if
settings
.
GENERATE_RANDOM_USER_CREDENTIALS
:
if
settings
.
GENERATE_RANDOM_USER_CREDENTIALS
:
create_account
=
create_random_account
(
create_account
)
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
@ensure_csrf_cookie
def
activate_account
(
request
,
key
):
def
activate_account
(
request
,
key
):
...
...
lms/djangoapps/branding/views.py
View file @
9eb1cce3
...
@@ -58,12 +58,30 @@ def auto_auth(request):
...
@@ -58,12 +58,30 @@ def auto_auth(request):
true.
true.
"""
"""
# log the user in
from
django.contrib.auth.models
import
User
student
.
views
.
create_account
(
request
)
from
django.contrib.auth
import
login
,
authenticate
from
random
import
randint
# activate account
request
.
user
.
is_active
=
True
# generate random user ceredentials from a small name space
request
.
user
.
save
()
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
# redirect to home-page
return
redirect
(
'root'
)
return
redirect
(
'root'
)
lms/envs/common.py
View file @
9eb1cce3
...
@@ -38,12 +38,13 @@ COURSEWARE_ENABLED = True
...
@@ -38,12 +38,13 @@ COURSEWARE_ENABLED = True
ENABLE_JASMINE
=
False
ENABLE_JASMINE
=
False
AUTOMATIC_AUTH_FOR_LOAD_TESTING
=
True
AUTOMATIC_AUTH_FOR_LOAD_TESTING
=
True
MAX_AUTO_AUTH_USERS
=
2
GENERATE_RANDOM_USER_CREDENTIALS
=
False
GENERATE_RANDOM_USER_CREDENTIALS
=
False
PERFSTATS
=
False
PERFSTATS
=
False
# automatic_auth should turn on random_cred of it needs to
#
#
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
#
GENERATE_RANDOM_USER_CREDENTIALS = GENERATE_RANDOM_USER_CREDENTIALS or AUTOMATIC_AUTH_FOR_LOAD_TESTING
DISCUSSION_SETTINGS
=
{
DISCUSSION_SETTINGS
=
{
'MAX_COMMENT_DEPTH'
:
2
,
'MAX_COMMENT_DEPTH'
:
2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment