예제 #1
0
 def test_editoruser_cannot_reach_full_metadata(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.editor_login)
     resource = resourceInfoType_model.objects.all()[0]
     resource_uuid = resource.storage_object.identifier
     response = client.get('{0}{1}/metadata/'.format(self.SYNC_BASE, resource_uuid))
     self.assertIsForbidden(response)
예제 #2
0
 def setUp(self):
     UserProfileTest.test_login = {
         REDIRECT_FIELD_NAME: '/{}'.format(DJANGO_BASE),
         LOGIN_FORM_KEY: 1,
         'username': '******',
         'password': '******',
     }
     # create some test organizations
     UserProfileTest.test_organization_1 = \
         Organization.objects.create(name='test_organization_1')
     UserProfileTest.test_organization_2 = \
         Organization.objects.create(name='test_organization_2')
     # create some test editor groups
     UserProfileTest.test_editor_group_1 = \
         EditorGroup.objects.create(name='test_editor_group_1')
     UserProfileTest.test_editor_group_2 = \
         EditorGroup.objects.create(name='test_editor_group_2')
     # get the two META-SHARE membership permissions
     _profile_ct = ContentType.objects.get_for_model(UserProfile)
     UserProfileTest.ms_full_member_perm = Permission.objects.get(
         content_type=_profile_ct, codename='ms_full_member')
     UserProfileTest.ms_assoc_member_perm = Permission.objects.get(
         content_type=_profile_ct, codename='ms_associate_member')
     self.test_user = test_utils.create_editor_user(
         UserProfileTest.test_login['username'], '*****@*****.**',
         UserProfileTest.test_login['password'],
         (UserProfileTest.test_editor_group_1,))
     self.client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
예제 #3
0
파일: tests.py 프로젝트: Atala/META-SHARE
 def setUp(self):
     self.test_user = test_utils.create_editor_user(
         UserProfileTest.test_login['username'], '*****@*****.**',
         UserProfileTest.test_login['password'],
         (UserProfileTest.test_editor_group_1,))
     self.client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
예제 #4
0
 def test_contact_form_sending(self):
     """
     Verifies that the submitting the contact form is possible.
     """
     # verify that submitting as an anonymous user is forbidden and we are
     # redirected to the login page
     client = Client()
     response = client.post(
         reverse(views.contact),
         data={
             'message':
             'This is a sufficiently long test message for the node '
             'maintainer contact form.',
             'subject':
             'Test Request'
         },
         follow=True)
     self.assertNotContains(
         response, 'We have received your message and successfully sent it')
     self.assertTemplateUsed(response, 'login.html')
     # verify that submitting with a normal/registered user is possible
     client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
     response = client.post(
         reverse(views.contact),
         data={
             'message':
             'This is a sufficiently long test message for the node '
             'maintainer contact form.',
             'subject':
             'Test Request'
         },
         follow=True)
     self.assertContains(
         response, 'We have received your message and successfully sent it')
예제 #5
0
 def setUp(self):
     UserProfileTest.test_login = {
         REDIRECT_FIELD_NAME: '/{}'.format(DJANGO_BASE),
         LOGIN_FORM_KEY: 1,
         'username': '******',
         'password': '******',
     }
     # create some test organizations
     UserProfileTest.test_organization_1 = \
         Organization.objects.create(name='test_organization_1')
     UserProfileTest.test_organization_2 = \
         Organization.objects.create(name='test_organization_2')
     # create some test editor groups
     UserProfileTest.test_editor_group_1 = \
         EditorGroup.objects.create(name='test_editor_group_1')
     UserProfileTest.test_editor_group_2 = \
         EditorGroup.objects.create(name='test_editor_group_2')
     # get the two META-SHARE membership permissions
     _profile_ct = ContentType.objects.get_for_model(UserProfile)
     UserProfileTest.ms_full_member_perm = Permission.objects.get(
         content_type=_profile_ct, codename='ms_full_member')
     UserProfileTest.ms_assoc_member_perm = Permission.objects.get(
         content_type=_profile_ct, codename='ms_associate_member')
     self.test_user = test_utils.create_editor_user(
         UserProfileTest.test_login['username'], '*****@*****.**',
         UserProfileTest.test_login['password'],
         (UserProfileTest.test_editor_group_1, ))
     self.client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
예제 #6
0
 def test_editoruser_cannot_reach_full_metadata(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.editor_login)
     resource = resourceInfoType_model.objects.all()[0]
     resource_uuid = resource.storage_object.identifier
     response = client.get('{0}{1}/metadata/'.format(
         self.SYNC_BASE, resource_uuid))
     self.assertIsForbidden(response)
예제 #7
0
파일: tests.py 프로젝트: MiltosD/CEFELRC
 def setUp(self):
     self.test_user = test_utils.create_editor_user(
         UserProfileTest.test_login['username'], '*****@*****.**',
         UserProfileTest.test_login['password'])
     #create the profile
     UserProfile.objects.create(user= self.test_user, \
                     affiliation = "AFF", \
                     country = "Greece",
                     )
     self.client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
예제 #8
0
파일: tests.py 프로젝트: MiltosD/CEFELRC
 def test_contact_form_access(self):
     """
     Verifies that the contact form page is only accessible by registered users.
     """
     # verify that anonymous access is forbidden and we are redirected to the
     # login page
     client = Client()
     response = client.get(reverse(views.contact), follow=True)
     self.assertNotContains(response, 'Contact Us')
     self.assertTemplateUsed(response, 'login.html')
     # verify that access with a normal/registered user is possible
     client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
     response = client.get(reverse(views.contact))
     self.assertContains(response, 'Contact Us')
     self.assertTemplateUsed(response, 'accounts/contact_maintainers.html')
예제 #9
0
 def test_contact_form_access(self):
     """
     Verifies that the contact form page is only accessible by registered users.
     """
     # verify that anonymous access is forbidden and we are redirected to the
     # login page
     client = Client()
     response = client.get(reverse(views.contact), follow=True)
     self.assertNotContains(response, 'Contact Node Maintainers')
     self.assertTemplateUsed(response, 'login.html')
     # verify that access with a normal/registered user is possible
     client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
     response = client.get(reverse(views.contact))
     self.assertContains(response, 'Contact Node Maintainers')
     self.assertTemplateUsed(response, 'accounts/contact_maintainers.html')
예제 #10
0
파일: tests.py 프로젝트: MiltosD/CEFELRC
 def test_contact_form_sending(self):
     """
     Verifies that the submitting the contact form is possible.
     """
     # verify that submitting as an anonymous user is forbidden and we are
     # redirected to the login page
     client = Client()
     response = client.post(reverse(views.contact), data={'message':
             'This is a sufficiently long test message for the node '
             'maintainer contact form.', 'subject': 'Test Request'},
         follow=True)
     self.assertNotContains(response,
          'We have received your message and will get back to you as soon')
     self.assertTemplateUsed(response, 'login.html')
     # verify that submitting with a normal/registered user is possible
     client = test_utils.get_client_with_user_logged_in(
         UserProfileTest.test_login)
     response = client.post(reverse(views.contact), data={'message':
             'This is a sufficiently long test message for the node '
             'maintainer contact form.', 'subject': 'Test Request'},
         follow=True)
     self.assertContains(response,
          'We have received your message and will get back to you as soon')
예제 #11
0
 def test_editoruser_cannot_reach_inventory(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.editor_login)
     response = client.get(self.INVENTORY_URL)
     self.assertIsForbidden(response)    
예제 #12
0
 def test_syncuser_get_inventory(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.syncuser_login)
     response = client.get(self.INVENTORY_URL)
     self.assertValidInventoryResponse(response)
예제 #13
0
 def test_editoruser_cannot_reach_inventory(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.editor_login)
     response = client.get(self.INVENTORY_URL + "?sync_protocol=1.0")
     self.assertIsForbidden(response)
예제 #14
0
 def test_syncuser_get_inventory(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.syncuser_login)
     response = client.get(self.INVENTORY_URL + "?sync_protocol=1.0")
     self.assertValidInventoryResponse(response)
예제 #15
0
 def test_normaluser_cannot_reach_inventory(self):
     settings.SYNC_NEEDS_AUTHENTICATION = True
     client = test_utils.get_client_with_user_logged_in(self.normal_login)
     response = client.get(self.INVENTORY_URL + "?sync_protocol=1.0")
     self.assertIsForbidden(response)