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
b8efb542
Commit
b8efb542
authored
May 13, 2015
by
Awais Qureshi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7951 from edx/awais786/ECOM-1531-fake-page-ssecure
ECOM-1531 adding the fake-page for softwar secure.
parents
53da306c
58b7e7fb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
219 additions
and
0 deletions
+219
-0
lms/djangoapps/verify_student/tests/fake_software_secure.py
+48
-0
lms/djangoapps/verify_student/tests/test_fake_software_secure.py
+76
-0
lms/djangoapps/verify_student/urls.py
+8
-0
lms/envs/common.py
+3
-0
lms/envs/devstack.py
+9
-0
lms/templates/verify_student/test/fake_softwaresecure_response.html
+75
-0
No files found.
lms/djangoapps/verify_student/tests/fake_software_secure.py
0 → 100644
View file @
b8efb542
"""
Fake Software Secure page for use in acceptance tests.
"""
from
django.conf
import
settings
from
django.contrib.auth.decorators
import
login_required
from
django.core.urlresolvers
import
reverse
from
django.utils.decorators
import
method_decorator
from
django.views.generic.base
import
View
from
edxmako.shortcuts
import
render_to_response
from
verify_student.models
import
SoftwareSecurePhotoVerification
class
SoftwareSecureFakeView
(
View
):
"""
Fake SoftwareSecure view for testing different photo verification statuses
and email functionality.
"""
@method_decorator
(
login_required
)
def
get
(
self
,
request
):
"""
Render a fake Software Secure page that will pick the most recent
attempt for a given user and pass it to the html page.
"""
context_dict
=
self
.
response_post_params
(
request
.
user
)
return
render_to_response
(
"verify_student/test/fake_softwaresecure_response.html"
,
context_dict
)
@classmethod
def
response_post_params
(
cls
,
user
):
"""
Calculate the POST params we want to send back to the client.
"""
access_key
=
settings
.
VERIFY_STUDENT
[
"SOFTWARE_SECURE"
][
"API_ACCESS_KEY"
]
context
=
{
'receipt_id'
:
None
,
'authorization_code'
:
'SIS {}:0000'
.
format
(
access_key
),
'results_callback'
:
reverse
(
'verify_student_results_callback'
)
}
try
:
most_recent
=
SoftwareSecurePhotoVerification
.
original_verification
(
user
)
context
[
"receipt_id"
]
=
most_recent
.
receipt_id
except
:
# pylint: disable=bare-except
pass
return
context
lms/djangoapps/verify_student/tests/test_fake_software_secure.py
0 → 100644
View file @
b8efb542
"""
Tests for the fake software secure response.
"""
from
django.test
import
TestCase
from
mock
import
patch
from
student.tests.factories
import
UserFactory
from
util.testing
import
UrlResetMixin
from
verify_student.models
import
SoftwareSecurePhotoVerification
class
SoftwareSecureFakeViewTest
(
UrlResetMixin
,
TestCase
):
"""
Base class to test the fake software secure view.
"""
def
setUp
(
self
,
**
kwargs
):
enable_software_secure_fake
=
kwargs
.
get
(
'enable_software_secure_fake'
,
False
)
with
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_SOFTWARE_SECURE_FAKE'
:
enable_software_secure_fake
}):
super
(
SoftwareSecureFakeViewTest
,
self
)
.
setUp
(
'verify_student.urls'
)
self
.
user
=
UserFactory
.
create
(
username
=
"test"
,
password
=
"test"
)
self
.
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
create
(
user
=
self
.
user
)
self
.
client
.
login
(
username
=
"test"
,
password
=
"test"
)
class
SoftwareSecureFakeViewDisabledTest
(
SoftwareSecureFakeViewTest
):
"""
Test the fake software secure response when feature flag
'ENABLE_SOFTWARE_SECURE_FAKE' is not enabled.
"""
def
setUp
(
self
):
super
(
SoftwareSecureFakeViewDisabledTest
,
self
)
.
setUp
(
enable_software_secure_fake
=
False
)
def
test_get_method_without_enable_feature_flag
(
self
):
"""
Test that the user gets 404 response if the feature flag
'ENABLE_SOFTWARE_SECURE_FAKE' is not enabled.
"""
response
=
self
.
client
.
get
(
'/verify_student/software-secure-fake-response'
)
self
.
assertEqual
(
response
.
status_code
,
404
)
class
SoftwareSecureFakeViewEnabledTest
(
SoftwareSecureFakeViewTest
):
"""
Test the fake software secure response when feature flag
'ENABLE_SOFTWARE_SECURE_FAKE' is enabled.
"""
def
setUp
(
self
):
super
(
SoftwareSecureFakeViewEnabledTest
,
self
)
.
setUp
(
enable_software_secure_fake
=
True
)
def
test_get_method_without_logged_in_user
(
self
):
"""
Test that the user gets 302 response if that user is not logged in.
"""
self
.
client
.
logout
()
response
=
self
.
client
.
get
(
'/verify_student/software-secure-fake-response'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_get_method
(
self
):
"""
Test that GET method of fake software secure view uses the most recent
attempt for the logged-in user.
"""
response
=
self
.
client
.
get
(
'/verify_student/software-secure-fake-response'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIn
(
'EdX-ID'
,
response
.
content
)
self
.
assertIn
(
'results_callback'
,
response
.
content
)
lms/djangoapps/verify_student/urls.py
View file @
b8efb542
...
...
@@ -149,3 +149,11 @@ urlpatterns = patterns(
name
=
"verify_student_incourse_reverify"
),
)
# Fake response page for incourse reverification ( software secure )
if
settings
.
FEATURES
.
get
(
'ENABLE_SOFTWARE_SECURE_FAKE'
):
from
verify_student.tests.fake_software_secure
import
SoftwareSecureFakeView
urlpatterns
+=
patterns
(
'verify_student.tests.fake_software_secure'
,
url
(
r'^software-secure-fake-response'
,
SoftwareSecureFakeView
.
as_view
()),
)
lms/envs/common.py
View file @
b8efb542
...
...
@@ -383,6 +383,9 @@ FEATURES = {
# Course discovery feature
'ENABLE_COURSE_DISCOVERY'
:
False
,
# Software secure fake page feature flag
'ENABLE_SOFTWARE_SECURE_FAKE'
:
False
,
}
# Ignore static asset files on import which match this pattern
...
...
lms/envs/devstack.py
View file @
b8efb542
...
...
@@ -146,3 +146,12 @@ SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd'
FEATURES
[
'ENABLE_COURSE_DISCOVERY'
]
=
True
FEATURES
[
'COURSES_ARE_BROWSEABLE'
]
=
True
HOMEPAGE_COURSE_MAX
=
9
# Software secure fake page feature flag
FEATURES
[
'ENABLE_SOFTWARE_SECURE_FAKE'
]
=
True
# Setting for the testing of Software Secure Result Callback
VERIFY_STUDENT
[
"SOFTWARE_SECURE"
]
=
{
"API_ACCESS_KEY"
:
"BBBBBBBBBBBBBBBBBBBB"
,
"API_SECRET_KEY"
:
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
,
}
lms/templates/verify_student/test/fake_softwaresecure_response.html
0 → 100644
View file @
b8efb542
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
<html>
<head><title>
Fake Software Secure Form
</title>
</head>
<body>
<p>
Fake Software Secure page
</p>
<p>
It will pick the most recent software secure attempt for a logged-in user.
</p>
<br>
<div>
<input
type=
"button"
value=
"PASS"
id=
"btn_pass"
>
<input
type=
"button"
value=
"FAIL"
id=
"btn_denied"
style=
"margin-left: 10px"
>
<input
type=
"button"
value=
"SYSTEM FAIL"
id=
"btn_error"
style=
"margin-left: 10px"
>
<input
type=
"button"
value=
"UNKNOWN ERROR"
id=
"btn_unknown_error"
style=
"margin-left: 10px"
>
</div>
<div
id=
"errors-info"
style=
"padding-top: 20px;color: red"
></div>
<div
id=
"success-info"
style=
"padding-top: 20px;color: green"
></div>
</body>
</html>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.min.js')}"
></script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
"#btn_pass"
).
click
(
function
(
e
){
e
.
preventDefault
();
ajax_post
(
$
(
this
).
val
(),
""
);
});
$
(
"#btn_denied"
).
click
(
function
(
e
){
e
.
preventDefault
();
ajax_post
(
$
(
this
).
val
(),
"failure"
);
});
$
(
"#btn_error"
).
click
(
function
(
e
){
e
.
preventDefault
();
ajax_post
(
$
(
this
).
val
(),
"system error"
);
});
$
(
"#btn_unknown_error"
).
click
(
function
(
e
){
e
.
preventDefault
();
ajax_post
(
$
(
this
).
val
(),
"unknown system error"
);
});
function
ajax_post
(
status
,
reason
){
var
data
=
{
"EdX-ID"
:
'${receipt_id}'
,
"Result"
:
status
,
"Reason"
:
reason
,
"MessageType"
:
""
};
$
(
'#errors-info'
).
html
(
''
);
$
(
'#success-info'
).
html
(
''
);
$
.
ajax
({
type
:
"POST"
,
url
:
'${results_callback}'
,
headers
:
{
"Authorization"
:
"${authorization_code}"
},
data
:
JSON
.
stringify
(
data
),
contentType
:
"application/json;"
,
success
:
function
()
{
$
(
'#success-info'
).
html
(
'status updated.'
);
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
'#errors-info'
).
html
(
jqXHR
.
responseText
);
}
});
}
});
</script>
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