예제 #1
0
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
예제 #2
0
파일: send.py 프로젝트: LeonardoXavier/f1
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
예제 #3
0
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