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)
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)
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)
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')
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)
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)
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)
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')
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')
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')
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)
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)
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)
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)
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)