def __init__(self): engine = create_engine(config.get('Database', 'db_url'), echo=False) session = scoped_session(sessionmaker(autoflush=True, autocommit=False)) session.configure(bind=engine) data.Base.metadata.create_all(engine) self.scan_app_dir(session) self.apps = {} self.groups = {} self.login = auth.Login() self.admin = admin.Admin() self.user = user.User() self.statistics = statistics.Statistics() self.reports = reports.Reports() dbapps = session.query(data.Application).all() for dbapp in dbapps: app = self.load_app(dbapp) if app != None: self.apps[app.id] = app app.enabled = dbapp.enabled session.commit() session.remove() engine.dispose() self.server_map() field.objectify_clean() self.no_SSL = False
import auth,cgi,cgitb form = cgi.FieldStorage() user = form.getvalue("user") password = form.getvalue("pass") login1 = auth.Login() login1.login(user,password)
"query QUERY_LIBRARY_TESTCASE_EDIT(\n $fieldFilter:Filter,\n $moduleFilter: Filter,\n $orderBy:Filter\n ){\n fields(\n filter:$fieldFilter,\n orderBy:$orderBy\n ){\n aliases,\n name,\n uuid,\n namePinyin,\n fieldType,\n key,\n defaultValue,\n createTime,\n hidden,\n required,\n canUpdate,\n builtIn,\n allowEmpty,\n options {\n uuid,\n value,\n color,\n bgColor\n },\n}\n \n testcaseModules(\n filter:$moduleFilter,\n groupBy:{\n testcaseLibrary:{}\n },\n orderBy: {\n isDefault: ASC,\n position: ASC\n }\n ){\n uuid,\n name,\n path,\n createTime,\n isDefault,\n position,\n key,\n testcaseCaseCount,\n testcaseLibrary{\n key,\n uuid,\n name,\n testcaseCaseCount,\n },\n parent{\n uuid,\n name,\n path,\n createTime,\n isDefault,\n position,\n key\n }\n }\n}", "variables": { "fieldFilter": { "hidden_in": [False], "pool_in": ["testcase"], "context": { "type_in": ["testcase_field_config"], "fieldConfigUUID_in": ["3BWci2q7"] } }, "moduleFilter": { "testcaseLibrary_in": ["H3hEkVvS"] }, "orderBy": { "createTime": "ASC" } } } response = requests.post(self.url, json=requestPayload, headers=self.login.common_header).json() print(json.dumps(response, ensure_ascii=False, indent="\t")) if __name__ == '__main__': login = auth.Login() testcaseFieldConfig = TestcaseFieldConfigs(login) # testcaseFieldConfig.getTestcaseFieldConfigs() testcaseFieldConfig.getField()
def __init__(self): self.login = auth.Login("saas")
import auth import requests import json login = auth.Login("private") url = login.server_url + '/team/' + login.team_uuid + '/res/attachments/upload' print(url) request_payload = { "type": "avatar", "name": "1.jpg", "description": "", "ignore_notice": True } response = requests.post(url, data=json.dumps(request_payload), headers=login.common_header) response_json = response.json() print(json.dumps(response_json, indent="\t")) upload_url = response_json["upload_url"] token = response_json["token"] file = [('file',('dep.txt',open('/Users/duxy/Downloads/dep.txt','rb'),'text/plain'))] data = {"token": token} # 为什么要用cookies,不用header? # 原因:上传文件的接口,公有云与私有云不一样,公有云是上传到七牛云上的,私有云是上传到客户的服务器的。所以后端只支持用cookies发送请求,如果上传到七牛云的话我们没法做校验header。 re = requests.post(upload_url, files=file, data=data, cookies=login.cookies) print(re.text)
import auth user = input('masukan username:'******'masukan password:') authentication = auth.Login(user, passwd) print(authentication.Auth())