Пример #1
0
 def testChangingSomeoneElsesProfile(self):
     setCurrentUser("*****@*****.**", "Administrator")
     register_new_user('SiteAdmin')
     site_admin_id = _get_my_profile().key.urlsafe()
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "NewUser1")
     register_new_user('NewUserOne')
     new_user_1_id = _get_my_profile().key.urlsafe()
     role_1_id = create_role("Test Role 1")
     set_playing(role_1_id)
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "NewUser2")
     ''' This code simulates an attack against the Model, using the Google Account ID to load another users Profile '''
     profile = ndb.Key(urlsafe=new_user_1_id).get()
     profile.playing = ndb.Key(urlsafe=role_1_id)
     self.assertRaises(DataModelException, profile.put)
     profile = ndb.Key(urlsafe=site_admin_id).get()
     profile.playing = ndb.Key(urlsafe=role_1_id)
     self.assertRaises(DataModelException, profile.put)
     register_new_user('NewUserTwo')
     ''' This code simulates an attack against the Model, using the Google Account ID to load another users Profile '''
     profile = ndb.Key(urlsafe=new_user_1_id).get()
     profile.playing = ndb.Key(urlsafe=role_1_id)
     self.assertRaises(DataModelException, profile.put)
     profile = ndb.Key(urlsafe=site_admin_id).get()
     profile.playing = ndb.Key(urlsafe=role_1_id)
     self.assertRaises(DataModelException, profile.put)
Пример #2
0
 def testLoginAndOut(self):
     setCurrentUser("*****@*****.**", "Administrator")
     self.assertRaises(NoUserNameException, _get_my_profile)
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "Administrator")
     self.assertRaises(NoUserNameException, _get_my_profile)
     register_new_user('AnotherUserTwo')
     logoutCurrentUser()
     setCurrentUser("*****@*****.**", "Administrator")
     self.assertIsInstance(_get_my_profile(), Profile)        
Пример #3
0
 def testNextSignup(self):
     setCurrentUser("*****@*****.**", "Administrator")
     self.assertRaises(NoUserNameException, _get_my_profile)
     self.assertRaises(NoUserNameException, _get_my_profile)
     register_new_user('SiteAdmin')
     self.assertIsInstance(_get_my_profile(), Profile)
     self.assertEquals('SiteAdmin', get_my_profile_name())
     self.assertEquals(1, SiteMasterProfile.query().count())
     self.assertEquals(1, Profile.query().count())
     logoutCurrentUser()
     self.assertRaises(NoUserException, _get_my_profile)
     setCurrentUser("*****@*****.**", "NewUser1")
     self.assertRaises(NoUserNameException, _get_my_profile)
     self.assertRaises(NoUserNameException, _get_my_profile)
     '''Should create a GameMaster for this new profile with its own Place for private conversations'''
     register_new_user('NewUserOne')
     '''Should have an profile now'''
     self.assertIsInstance(_get_my_profile(), Profile)
     '''Should be called whatever it was set up as'''
     self.assertEquals('NewUserOne', get_my_profile_name())
     self.assertEquals(2, Profile.query().count())
     logoutCurrentUser()
     self.assertRaises(NoUserException, _get_my_profile)
Пример #4
0
 def testFirstSignup(self):
     setCurrentUser("*****@*****.**", "Administrator")
     '''Should fail repeatedly with a NoUserNameException'''
     self.assertRaises(NoUserNameException, _get_my_profile)
     self.assertRaises(NoUserNameException, _get_my_profile)
     '''Should create the Site Administrator with its own place for template Roles'''
     register_new_user('SiteAdmin')
     '''Should have a SiteAdmin now'''
     self.assertIsInstance(_get_my_profile(), SiteMasterProfile)
     self.assertEquals(SiteMasterProfile.query().count(), 1)
     self.assertEquals(Profile.query().count(), 1)
     '''Should be called whatever it was set up as'''
     self.assertEquals('SiteAdmin', get_my_profile_name())
     '''Check number of entities'''
     self.assertEquals(1, SiteMasterProfile.query().count())
     '''Should just fail with a NoUserException if logged out'''
     logoutCurrentUser()
     self.assertRaises(NoUserException, _get_my_profile)