def __init__(self, addon, crashreport, user_agent): self.addon = addon self.instanceName = 'gdrive' self.user_agent = user_agent self.crashreport = crashreport # self.crashreport.sendError('test','test') try: username = self.addon.getSetting(self.instanceName+'_username') except: username = '' self.authorization = authorization.authorization(username) self.cookiejar = cookielib.CookieJar() self.user_agent = user_agent #token? if (not self.authorization.loadToken(self.instanceName,addon, 'wise')): self.login() return
def test_01_user_created_correctly(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_user_create = 'management/users/create' self.url_user_create = '{}/{}'.format(HOST, self.command_user_create) words = ["python", "jumble", "easy", "difficult", "answer", "xophone"] newValue = random.choice(words) email_value = time.strftime("%d%m%Y" + "%H%M%S") + "@" + "test.com" userdata = json.dumps({ "full_name": newValue, "email": email_value, "password": "******", "password_confirmation": "12345678", "birthday": "1990-06-20", "gender": "male" }) response = self.s.post(self.url_user_create, data=userdata, headers=headers) self.assertEqual(response.status_code, SUCCESS)
def test_01_image_is_attached_successfully(self): token, user_id = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.partner_id = 'partner_id' partner_id = 6 self.image_id = 'image_id' image_id = 612 self.command_image_attach = 'management/partners/image/attach' self.command_image_detach = 'management/partners/image/detach' self.url_image_attach = '{}/{}?{}={}&{}={}'.format( HOST, self.command_image_attach, self.partner_id, partner_id, self.image_id, image_id) response = self.s.post(self.url_image_attach, headers=headers) self.assertEqual(response.status_code, ADDED) self.url_image_detach = '{}/{}?{}={}&{}={}'.format( HOST, self.command_image_detach, self.partner_id, partner_id, self.image_id, image_id) response = self.s.delete(self.url_image_detach, headers=headers) self.assertEqual(response.status_code, FINISHED)
def test_01_image_is_upload_successfully(self): token, user_id = authorization() headers = {'Authorization': token} self.partner_id = 'partner_id' self.image_id = 'image_id' self.command_image_upload = 'management/images/upload' self.url_image_upload = '{}/{}'.format(HOST, self.command_image_upload) postdata = {} files = {'image': open('picture.jpg', 'rb')} response = self.s.post(self.url_image_upload, headers=headers, data=postdata, files=files) identificator = json.loads(response.content)['id'] self.assertEqual(response.status_code, SUCCESS) self.command_image_delete = 'management/images/delete' self.url_image_delete = '{}/{}/{}'.format(HOST, self.command_image_delete, identificator) response = self.s.delete(self.url_image_delete, headers=headers) self.assertEqual(response.status_code, NO_CONTENT)
def test_03_user_not_created_wrong_email_format(self): token, index = authorization() time.sleep(3) headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_user_create = 'management/users/create' self.url_user_create = '{}/{}'.format(HOST, self.command_user_create) words = [ "python", "jumble", "easy", "difficult", "answer", "xylophone" ] newvalue = random.choice(words) + random.choice(words) nameunique = "testuser" + random.choice(words) + random.choice( words) + "@" + random.choice(words) + ".com" userdata = json.dumps({ "full_name": newvalue, "email": "test", "password": "******", "password_confirmation": "12345678", "birthday": "1990-20-06" }) response = self.s.post(self.url_user_create, data=userdata, headers=headers) self.assertEqual(response.status_code, BADDATA)
def __init__(self, *a, **kw): super(Test_012_Tag_Attaching_To_Category, self).__init__(*a, **kw) self.s = requests.Session() token, index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token }
def __init__(self, *a, **kw): super(Test_001_get_combined_tags, self).__init__(*a, **kw) self.s = requests.Session() self.token, self.index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': self.token }
def __init__(self, *a, **kw): super(Test_022_offer_Extra_Categories, self).__init__(*a, **kw) self.s = requests.Session() token, index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token }
def __init__(self, *a, **kw): super(Test_020_ServerActions, self).__init__(*a, **kw) self.s = requests.Session() token, index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token }
def __init__(self, *a, **kw): super(Test_011_category_Update_And_Delete, self).__init__(*a, **kw) self.s = requests.Session() token, index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token }
def __init__(self, *a, **kw): super(Test_021_offer_CRUD, self).__init__(*a, **kw) self.s = requests.Session() self.token, self.index = authorization() self.config = SafeConfigParser() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': self.token }
def __init__(self, *a, **kw): super(Test_007_Role_Attach_and_Detach, self).__init__(*a, **kw) self.s = requests.Session() token, index = authorization() self.headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.config = SafeConfigParser()
def test_01_all_users_opened(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } response = self.s.get(self.url_all_users, headers=headers) self.assertEqual(response.status_code, SUCCESS)
def player_home(): if request.method == "POST": username = request.form["username"] password = request.form["password"] access, player = authorization(username, password) else: player = 'Wait for it buddy' return player
def login(): if request.method == "POST": username = request.form["username"] password = request.form["password"] print(username, password) access, response = authorization(username, password) else: response = 'Hi' return jsonify(access)
def test_01_all_partners_opened(self): self.command_all_partners = 'management/partners' self.url_all_partners = '{}/{}'.format(HOST, self.command_all_partners) token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } response = self.s.get(self.url_all_partners, headers=headers) self.assertEqual(response.status_code, SUCCESS)
def test_01_refreshed_token_successfully(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } response = self.s.get(self.url_refresh_token, headers=headers) newToken = response.headers['Authorization'] self.assertNotEqual(token, newToken) self.assertEqual(response.status_code, MAIL_SENT)
def test_01_attaching_tags_to_category(self): token, index = authorization() self.command_category_create = 'management/categories/create' headers = {'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token} self.url_category_create = '{}/{}'.format(HOST, self.command_category_create) userdata = json.dumps({"parent_id": 3, "is_last": "false", "title": "string", "description": "string"}) response = self.s.post(self.url_category_create, data=userdata, headers=headers) self.assertEqual(response.status_code, SUCCESS) index = json.loads(response.content)['id'] self.command_tags_create = 'management/tags/create' self.url_tags_create = '{}/{}'.format(HOST, self.command_tags_create) userdata = json.dumps({"name": "TestName"}) response = self.s.post(self.url_tags_create, data=userdata, headers=headers) identifier = json.loads(response.content)['id'] self.assertEqual(response.status_code, SUCCESS) self.command_tag_attaching_to_category = 'management/categories/attach/tag' self.category_id = 'category_id' self.tag_id = 'tag_id' self.tag_type = 'tag_type=App\\Tag' self.matching_criteria = 'matching_criteria=areWordsSimilar' self.importance = 'importance=medium' self.url_tag_attaching_to_category = '{}/{}?{}={}&{}={}&{}&{}&{}'.format(HOST, self.command_tag_attaching_to_category, self.category_id, index, self.tag_id, identifier, self.tag_type, self.matching_criteria, self.importance) response = self.s.post(self.url_tag_attaching_to_category, headers=headers) self.assertEqual(response.status_code, NO_CONTENT) self.command_tag_detaching_to_category = 'management/categories/detach/tag' self.url_tag_detaching_to_category = '{}/{}?{}={}&{}={}&{}'.format(HOST, self.command_tag_detaching_to_category, self.category_id, index, self.tag_id, identifier, self.tag_type) response = self.s.post(self.url_tag_detaching_to_category, headers=headers) self.assertEqual(response.status_code, NO_CONTENT) self.command_category_delete = 'management/categories/delete' self.url_category_delete = '{}/{}/{}'.format(HOST, self.command_category_delete, index) response = self.s.delete(self.url_category_delete, headers=headers) self.assertEqual(response.status_code, NO_CONTENT)
def test_01_image_is_attached_successfully(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_business_create = 'management/businesses/create' self.url_business_create = '{}/{}'.format(HOST, self.command_business_create) email_value = time.strftime("%d%m%Y" + "%H%M%S") + "@" + "test.com" userdata = json.dumps \ ({"partner_id": 1, "email": email_value, "business_id_by_partner": "string", "address": "string", "geo_latitude": "48.92279", "geo_longitude": "22.4519749", "title": "forImage", "TestImage": "string"}) response = self.s.post(self.url_business_create, data=userdata, headers=headers) self.assertEqual(response.status_code, SUCCESS) identificator = json.loads(response.content)['id'] self.command_businesses_image_attach = 'management/businesses/image/attach' self.command_businesses_image_detach = 'management/businesses/image/detach' self.business_id = 'business_id' self.image_id = 'image_id' image_id = 612 self.url_businesses_image_attach = '{}/{}?{}={}&{}={}'.format( HOST, self.command_businesses_image_attach, self.business_id, identificator, self.image_id, image_id) response = self.s.post(self.url_businesses_image_attach, headers=headers) self.assertEqual(response.status_code, ADDED) self.url_businesses_image_detach = '{}/{}?{}={}&{}={}'.format( HOST, self.command_businesses_image_detach, self.business_id, identificator, self.image_id, image_id) response = self.s.post(self.url_businesses_image_detach, headers=headers) self.assertEqual(response.status_code, FINISHED) self.command_business_delete = 'management/businesses/delete' self.url_business_delete = '{}/{}/{}'.format( HOST, self.command_business_delete, identificator) response = self.s.delete(self.url_business_delete, headers=headers) self.assertEqual(response.status_code, NO_CONTENT)
def __init__(self, PLUGIN_URL, addon, instanceName, user_agent): self.PLUGIN_URL = PLUGIN_URL self.addon = addon self.instanceName = instanceName try: username = self.addon.getSetting(self.instanceName + '_username') except: username = '' self.authorization = authorization.authorization(username) self.cookiejar = cookielib.CookieJar() self.user_agent = user_agent self.login()
def test_01_user_profile_edited(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } edited_name = "EditedName" userdata = json.dumps({"full_name": edited_name}) response = self.s.patch(self.url_profile_edit, data=userdata, headers=headers) self.assertEqual(response.status_code, SUCCESS) self.assertEqual( json.loads(response.content)["full_name"], edited_name)
def test_01_user_page_showed_correctly(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_all_users = 'management/users' self.url_all_users = '{}/{}'.format(HOST, self.command_all_users) users = self.s.get(self.url_all_users, headers=headers) self.command_user_show = 'management/users/show' self.url_user_show = '{}/{}/{}'.format(HOST, self.command_user_show, index) response = self.s.get(self.url_user_show, headers=headers) self.assertEqual(response.status_code, SUCCESS)
def __init__(self, PLUGIN_URL, addon, instanceName, user_agent): self.PLUGIN_URL = PLUGIN_URL self.addon = addon self.instanceName = instanceName try: username = self.addon.getSetting(self.instanceName+'_username') except: username = '' self.authorization = authorization.authorization(username) self.cookiejar = cookielib.CookieJar() self.user_agent = user_agent self.login();
def main(self): self.vk = vk_api() auth = authorization(self.vk) user_info = auth.getCurrentUser() self.gui = gui_controller() if user_info is None: auth.showLoginWindow() user_info = auth.getCurrentUser() self.init_app() self.gui.getGtk().main() return None
def __init__(self, proxies=None, apikey=None): """ Creates an instance of the ZAP api client. :Parameters: - `proxies`: dictionary of ZAP proxies to use. Note that all of the other classes in this directory are generated new ones will need to be manually added to this file """ self.__proxies = proxies or { 'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080' } self.__apikey = apikey self.acsrf = acsrf(self) self.ajaxSpider = ajaxSpider(self) self.ascan = ascan(self) self.authentication = authentication(self) self.authorization = authorization(self) self.autoupdate = autoupdate(self) self.brk = brk(self) self.context = context(self) self.core = core(self) self.forcedUser = forcedUser(self) self.httpsessions = httpSessions(self) self.importLogFiles = importLogFiles(self) self.params = params(self) self.pnh = pnh(self) self.pscan = pscan(self) self.reveal = reveal(self) self.script = script(self) self.search = search(self) self.selenium = selenium(self) self.sessionManagement = sessionManagement(self) self.spider = spider(self) self.stats = stats(self) self.users = users(self) # not very nice, but prevents warnings when accessing the ZAP API via https requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def __init__(self, proxies=None, apikey=None): """ Creates an instance of the ZAP api client. :Parameters: - `proxies`: dictionary of ZAP proxies to use. Note that all of the other classes in this directory are generated new ones will need to be manually added to this file """ self.__proxies = proxies or { 'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080' } self.__apikey = apikey self.acsrf = acsrf(self) self.ajaxSpider = ajaxSpider(self) self.ascan = ascan(self) self.authentication = authentication(self) self.authorization = authorization(self) self.autoupdate = autoupdate(self) self.brk = brk(self) self.context = context(self) self.core = core(self) self.forcedUser = forcedUser(self) self.httpsessions = httpSessions(self) self.importLogFiles = importLogFiles(self) self.params = params(self) self.pnh = pnh(self) self.pscan = pscan(self) self.reveal = reveal(self) self.script = script(self) self.search = search(self) self.selenium = selenium(self) self.sessionManagement = sessionManagement(self) self.spider = spider(self) self.stats = stats(self) self.users = users(self) # not very nice, but prevents warnings when accessing the ZAP API via https requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def test_02_user_not_created_empty_values(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_user_create = 'management/users/create' self.url_user_create = '{}/{}'.format(HOST, self.command_user_create) userdata = json.dumps({ "full_name": "", "email": "", "password": "", "password_confirmation": "", "birthday": "" }) response = self.s.post(self.url_user_create, data=userdata, headers=headers) self.assertEqual(response.status_code, BADDATA)
def test_01_user_update_correctly(self): token, index = authorization() headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.command_user_update = 'management/users/update' self.url_user_update = '{}/{}/{}'.format(HOST, self.command_user_update, index) userdata = json.dumps({ "full_name": "User Updated", "birthday": "1990-10-20" }) response = self.s.patch(self.url_user_update, data=userdata, headers=headers) updated_name = json.loads(response.content)['full_name'] self.assertEqual(response.status_code, SUCCESS) self.assertEqual(updated_name, "User Updated")
def __init__(self, proxies={ 'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080' }): """ Creates an instance of the ZAP api client. :Parameters: - `proxies`: dictionary of ZAP proxies to use. Note that all of the other classes in this directory are generated new ones will need to be manually added to this file """ self.__proxies = proxies self.acsrf = acsrf(self) self.ajaxSpider = ajaxSpider(self) self.ascan = ascan(self) self.authentication = authentication(self) self.authorization = authorization(self) self.autoupdate = autoupdate(self) self.brk = brk(self) self.context = context(self) self.core = core(self) self.forcedUser = forcedUser(self) self.httpsessions = httpSessions(self) self.importLogFiles = importLogFiles(self) self.params = params(self) self.pnh = pnh(self) self.pscan = pscan(self) self.reveal = reveal(self) self.script = script(self) self.search = search(self) self.selenium = selenium(self) self.sessionManagement = sessionManagement(self) self.spider = spider(self) self.stats = stats(self) self.users = users(self)
def test_01_user_deleted_correctly(self): token, index = authorization() #Creating user before deleting self.command_signup = 'auth/signup' self.url_signup = '{}/{}'.format(HOST, self.command_signup) headers = {'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER} email_value = time.strftime("%d%m%Y" + "%H%M%S") + "@" + "test.com" userdata = json.dumps({"email": email_value, "full_name": "Test User"}) response = self.s.post(self.url_signup, data=userdata, headers=headers) user_id = json.loads(response.content)['id'] self.command_user_delete = 'management/users/delete' headers = { 'content-type': DEFAULT_HEADER, 'accept': DEFAULT_HEADER, 'Authorization': token } self.url_user_delete = '{}/{}/{}'.format(HOST, self.command_user_delete, user_id) response = self.s.delete(self.url_user_delete, headers=headers) self.assertEqual(response.status_code, NO_CONTENT)
def main(self): self.vk = vk_api() auth = authorization(self.vk) user_info = auth.getCurrentUser() self.gui = gui_controller() if user_info is None: auth.showLoginWindow() user_info = auth.getCurrentUser() self.init_app() self.gui.getGtk().main() return None
def __init__(self, proxies={'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}): """ Creates an instance of the ZAP api client. :Parameters: - `proxies`: dictionary of ZAP proxies to use. Note that all of the other classes in this directory are generated new ones will need to be manually added to this file """ self.__proxies = proxies self.acsrf = acsrf(self) self.ajaxSpider = ajaxSpider(self) self.ascan = ascan(self) self.authentication = authentication(self) self.authorization = authorization(self) self.autoupdate = autoupdate(self) self.brk = brk(self) self.context = context(self) self.core = core(self) self.forcedUser = forcedUser(self) self.httpsessions = httpSessions(self) self.importLogFiles = importLogFiles(self) self.params = params(self) self.pnh = pnh(self) self.pscan = pscan(self) self.reveal = reveal(self) self.script = script(self) self.search = search(self) self.selenium = selenium(self) self.sessionManagement = sessionManagement(self) self.spider = spider(self) self.stats = stats(self) self.users = users(self)
def data(): s = request.environ["beaker.session"] authorization(request, s) result = {"data": "Some data for the user " + s["username"]} return json.dumps(result)
def __init__(self, PLUGIN_URL, addon, instanceName, user_agent): self.PLUGIN_URL = PLUGIN_URL self.addon = addon self.instanceName = instanceName self.crashreport = crashreport.crashreport(self.addon) # self.crashreport.sendError('test','test') try: username = self.addon.getSetting(self.instanceName+'_username') except: username = '' self.authorization = authorization.authorization(username) # hive specific *** self.isPremium = True try: if int(self.addon.getSetting(self.instanceName+'_type')) == 1: self.isPremium = True else: self.isPremium = False except: self.isPremium = True try: if self.isPremium: self.skipUnwatchable = self.addon.getSetting('hide_unwatchable') else: self.skipUnwatchable = self.addon.getSetting('free_hide_unwatchable') except: self.skipUnwatchable = False if self.skipUnwatchable == 'true': self.skipUnwatchable = True else: self.skipUnwatchable = False #*** self.cookiejar = cookielib.CookieJar() self.user_agent = user_agent # hive specific *** #token? if (not self.authorization.loadToken(self.instanceName,addon, 'token')): self.login() self.isLibrary = False try: if self.addon.getSetting('gdrive_library') == 'true': self.isLibrary = True else: self.isLibrary = False except: self.isLibrary = False if self.isLibrary: self.library = gSpreadsheets.gSpreadsheets(self.addon,self.crashreport,self.user_agent) spreadsheets = self.library.getSpreadsheetList() worksheets = self.library.getSpreadsheetWorksheets(spreadsheets['Hive']) self.worksheet = '' try: self.worksheet = worksheets['content'] except: self.worksheet = self.library.createWorksheet(spreadsheets['Hive'],'content',10,5)
def __init__(self, PLUGIN_URL, addon, instanceName, user_agent): self.PLUGIN_URL = PLUGIN_URL self.addon = addon self.instanceName = instanceName self.crashreport = crashreport.crashreport(self.addon) # self.crashreport.sendError('test','test') try: username = self.addon.getSetting(self.instanceName + '_username') except: username = '' self.authorization = authorization.authorization(username) # hive specific *** self.isPremium = True try: if int(self.addon.getSetting(self.instanceName + '_type')) == 1: self.isPremium = True else: self.isPremium = False except: self.isPremium = True try: if self.isPremium: self.skipUnwatchable = self.addon.getSetting( 'hide_unwatchable') else: self.skipUnwatchable = self.addon.getSetting( 'free_hide_unwatchable') except: self.skipUnwatchable = False if self.skipUnwatchable == 'true': self.skipUnwatchable = True else: self.skipUnwatchable = False #*** self.cookiejar = cookielib.CookieJar() self.user_agent = user_agent # hive specific *** #token? if (not self.authorization.loadToken(self.instanceName, addon, 'token')): self.login() self.isLibrary = False try: if self.addon.getSetting('gdrive_library') == 'true': self.isLibrary = True else: self.isLibrary = False except: self.isLibrary = False if self.isLibrary: self.library = gSpreadsheets.gSpreadsheets(self.addon, self.crashreport, self.user_agent) spreadsheets = self.library.getSpreadsheetList() worksheets = self.library.getSpreadsheetWorksheets( spreadsheets['Hive']) self.worksheet = '' try: self.worksheet = worksheets['content'] except: self.worksheet = self.library.createWorksheet( spreadsheets['Hive'], 'content', 10, 5)
def __init__(self, *a, **kw): super(Test_004_offer_liking_disliking, self).__init__(*a, **kw) self.token, self.index = authorization() self.s = requests.Session()