Commit 16fb06c9 authored by Romain Courteaud's avatar Romain Courteaud

[officejs_test] Check opening and acception the Software Publication

parent e5b483f3
......@@ -26,12 +26,10 @@ class TestOfficeJSScenario(SecurityTestCase):
def createNewUser(self,
first_name="John_test",
last_name="Smith_test",
reference="TEST_OFFICEJS_",
email="john.smith@test.com"):
email="john.smith@example.com"):
"""
Add new member using script for the website sign-in
"""
reference += "%s" % time.time()
user = self.portal.person_module.newContent(
portal_type="Person",
first_name=first_name,
......@@ -44,17 +42,37 @@ class TestOfficeJSScenario(SecurityTestCase):
assignment.open()
return user
def createNewAdmin(self,
first_name="Brandon_test",
last_name="Cougar_test",
email="brandon.cougar@example.com"):
"""
Add new member using script for the website sign-in
"""
user = self.portal.person_module.newContent(
portal_type="Person",
first_name=first_name,
last_name=last_name,
default_email_coordinate_text=email,
career_role_list=["administration"]
)
user.validate()
assignment = user.newContent(portal_type="Assignment", group="my_group")
assignment.open()
return user
def test_01_user_can_contribute(self):
timestamp = "%s" % time.time()
###################################
### Manager: Create user
person = self.createNewUser()
person_user = self.createNewUser()
person_admin = self.createNewAdmin()
self.tic()
###################################
### User: submit application
self.logout()
self.login(person.getUserId())
self.login(person_user.getUserId())
import_file = LocalStringIO('your.zip')
......@@ -99,7 +117,7 @@ class TestOfficeJSScenario(SecurityTestCase):
page_content = response.read()
self.assertTrue(
'document.location.replace("%s/")' % web_section.getId() in page_content,
'document.location.replace("development/")' in page_content,
page_content
)
self.assertTrue(
......@@ -139,7 +157,7 @@ class TestOfficeJSScenario(SecurityTestCase):
page_content = response.read()
self.assertEquals("""CACHE MANIFEST
# %s""" % web_section.getId(),
# development""",
page_content
)
self.assertEquals(response.status, 200)
......@@ -184,3 +202,136 @@ class TestOfficeJSScenario(SecurityTestCase):
None
)
self.assertEquals(response.getheader('Vary'), None)
###################################
### User: open the publication to be accepted
self.logout()
self.login(person_user.getUserId())
software_publication = self.portal.portal_catalog.getResultValue(
portal_type='Software Publication',
reference='SP-%s' % web_section.getId()
)
software_publication.open()
self.tic()
###################################
### Anonymous: access the redirect application
self.logout()
api_scheme, api_netloc, api_path, api_query, \
api_fragment = urlparse.urlsplit(self.portal.absolute_url())
connection = httplib.HTTPConnection(api_netloc)
connection.request(
method='GET',
url='%s/' % web_section.getParentValue().absolute_url()
)
response = connection.getresponse()
page_content = response.read()
self.assertTrue(
'document.location.replace("development/")' in page_content,
page_content
)
self.assertTrue(
'manifest="WebSection_renderOfficeJSRedirectAppCache"' in page_content,
page_content
)
self.assertEquals(response.status, 200)
self.assertEquals(
response.getheader('Cache-Control'),
'max-age=0, public, must-revalidate'
)
self.assertEquals(
response.getheader('Content-Type'),
'text/html; charset=utf-8'
)
self.assertEquals(
response.getheader('Content-Security-Policy'),
"default-src 'self'; script-src 'unsafe-inline';"
)
self.assertEquals(
response.getheader('X-Frame-Options'),
'SAMEORIGIN'
)
self.assertEquals(
response.getheader('Vary'),
'Accept-Language,Cookie,Authorization,Accept-Encoding'
)
###################################
### Site admin: accept the software publication
self.logout()
self.login(person_admin.getUserId())
software_publication.accept()
self.tic()
###################################
### Anonymous: access the redirect application
self.logout()
connection.request(
method='GET',
url='%s/' % web_section.getParentValue().absolute_url()
)
response = connection.getresponse()
page_content = response.read()
self.assertTrue(
'document.location.replace("%s/")' % web_section.getId() in page_content,
page_content
)
self.assertTrue(
'manifest="WebSection_renderOfficeJSRedirectAppCache"' in page_content,
page_content
)
self.assertEquals(response.status, 200)
self.assertEquals(
response.getheader('Cache-Control'),
'max-age=0, public, must-revalidate'
)
self.assertEquals(
response.getheader('Content-Type'),
'text/html; charset=utf-8'
)
self.assertEquals(
response.getheader('Content-Security-Policy'),
"default-src 'self'; script-src 'unsafe-inline';"
)
self.assertEquals(
response.getheader('X-Frame-Options'),
'SAMEORIGIN'
)
self.assertEquals(
response.getheader('Vary'),
'Accept-Language,Cookie,Authorization,Accept-Encoding'
)
###################################
### Anonymous: access the redirect application appcache
connection.request(
method='GET',
url='%s/WebSection_renderOfficeJSRedirectAppCache' % web_section.getParentValue().absolute_url()
)
response = connection.getresponse()
page_content = response.read()
self.assertEquals("""CACHE MANIFEST
# %s""" % web_section.getId(),
page_content
)
self.assertEquals(response.status, 200)
self.assertEquals(
response.getheader('Content-Type'),
'text/cache-manifest; charset=utf-8'
)
self.assertEquals(
response.getheader('Cache-Control'),
'max-age=0, public, must-revalidate'
)
self.assertEquals(
response.getheader('Vary'),
None
)
......@@ -46,10 +46,10 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 89, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W: 89, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W: 89, 4: Unused variable \'api_scheme\' (unused-variable)</string>
<string>W: 90, 6: Unused variable \'api_fragment\' (unused-variable)</string>
<string>W:107, 28: Unused variable \'api_path\' (unused-variable)</string>
<string>W:107, 38: Unused variable \'api_query\' (unused-variable)</string>
<string>W:107, 4: Unused variable \'api_scheme\' (unused-variable)</string>
<string>W:108, 6: Unused variable \'api_fragment\' (unused-variable)</string>
</tuple>
</value>
</item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment