def test_bad_user_permissions_form_rendering(self): # Test handling of permissions not stored in entity as a list of values create_user_permissions(self.testcoll, "baduserperms", user_permissions="VIEW CREATE UPDATE DELETE" ) u = entitydata_edit_url( "edit", "testcoll", layout.USER_TYPEID, "baduserperms", view_id="User_view" ) with SuppressLogging(logging.WARNING): r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") field_vals = default_fields( coll_id="testcoll", type_id=layout.USER_TYPEID, entity_id="baduserperms", tooltip=context_view_field(r.context, 4, 0)['field_help'] ) formrow5 = """ <div class="small-12 columns" title="%(tooltip)s"> <div class="row view-value-row"> <div class="%(label_classes)s"> <span>Permissions</span> </div> <div class="%(input_classes)s"> <input type="text" size="64" name="User_permissions" placeholder="(user permissions; e.g. 'VIEW CREATE UPDATE DELETE CONFIG')" value="VIEW CREATE UPDATE DELETE"/> </div> </div> </div> """%field_vals(width=12) # log.info(r.content) self.assertContains(r, formrow5, html=True) return
def test_bad_user_permissions_form_rendering(self): # Test handling of permissions not stored in entity as a list of values create_user_permissions(self.testcoll, "baduserperms", user_permissions="VIEW CREATE UPDATE DELETE") u = entitydata_edit_url("edit", "testcoll", "_user", "baduserperms", view_id="User_view") with SuppressLogging(logging.WARNING): r = self.client.get(u) self.assertEqual(r.status_code, 200) self.assertEqual(r.reason_phrase, "OK") field_vals = default_fields(coll_id="testcoll", type_id="_user", entity_id="baduserperms") formrow5 = """ <div class="small-12 columns"> <div class="row"> <div class="%(label_classes)s"> <p>Permissions</p> </div> <div class="%(input_classes)s"> <input type="text" size="64" name="User_permissions" placeholder="(user permissions; e.g. 'VIEW CREATE UPDATE DELETE')" value="VIEW CREATE UPDATE DELETE"/> </div> </div> </div> """ % field_vals(width=12) # log.info(r.content) self.assertContains(r, formrow5, html=True) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) # self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpassword') # self.user.save() # self.client = Client(HTTP_HOST=TestHost) # Login and permissions create_test_user(None, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) create_user_permissions( self.testsite.site_data_collection(), "testuser", user_permissions= [ "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG" , "CREATE_COLLECTION", "DELETE_COLLECTION" ] ) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.uri = reverse("AnnalistSiteView") self.homeuri = reverse("AnnalistHomeView") self.profileuri = reverse("AnnalistProfileView") # Login and permissions create_test_user(None, "testuser", "testpassword") self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) create_user_permissions( self.testsite.site_data_collection(), "testuser", user_permissions= [ "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG" , "CREATE_COLLECTION", "DELETE_COLLECTION" ] ) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll")) self.annalcoll = Collection.load(self.testsite, layout.SITEDATA_ID) self.no_options = [FieldChoice('', label="(no options)")] # For checking Location: header values... self.continuation_url = (TestHostUri + entitydata_list_type_url( coll_id="testcoll", type_id=layout.VOCAB_TYPEID)) # Login and permissions create_test_user(self.testcoll, "testuser", "testpassword") create_user_permissions(self.annalcoll, "testuser", user_permissions=["VIEW"]) self.client = Client(HTTP_HOST=TestHost) loggedin = self.client.login(username="******", password="******") self.assertTrue(loggedin) return
def create_user(self, user_id): # Create placeholder for testing return create_user_permissions( self.testcoll, user_id, ["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"])