def getCSRF(): threadContext = HTTPPluginControl.getThreadHTTPClientContext() CookieModule.discardAllCookies(threadContext) result = request1.GET(url0 + '/api/account/get') assert result.getStatusCode() == 200, result csrf = linkdrop = None for cookie in CookieModule.listAllCookies(threadContext): if cookie.name == "linkdrop": linkdrop = cookie if cookie.name == "csrf": csrf = cookie.value assert csrf and linkdrop return csrf, linkdrop
def getCSRF(): threadContext = HTTPPluginControl.getThreadHTTPClientContext() CookieModule.discardAllCookies(threadContext) result = request1.GET(linkdrop_host + '/api/account/get') assert result.getStatusCode()==200, result csrf = linkdrop = None for cookie in CookieModule.listAllCookies(threadContext): if cookie.name == "linkdrop": linkdrop = cookie if cookie.name == "csrf": csrf = cookie.value assert csrf and linkdrop return csrf, linkdrop
def authService(): threadContext = HTTPPluginControl.getThreadHTTPClientContext() CookieModule.discardAllCookies(threadContext) # Call authorize requesting we land back on /account/get - after # a couple of redirects for auth, we should wind up with the data from # account/get - which should now include our account info. result = request1.POST(linkdrop_host + '/api/account/authorize', ( NVPair('domain', linkdrop_service), NVPair('end_point_success', '/api/account/get'), NVPair('end_point_auth_failure', '/current/send/auth.html#oauth_failure'), ), ( NVPair('Content-Type', 'application/x-www-form-urlencoded'), )) assert result.getStatusCode()==200, result data = json_loads(result.getText()) assert data, 'account/get failed to return data' userid = data[0]['accounts'][0]['userid'] for cookie in CookieModule.listAllCookies(threadContext): if cookie.name == "linkdrop": linkdrop_cookie = cookie assert linkdrop_cookie return userid, linkdrop_cookie