pyresttest icon indicating copy to clipboard operation
pyresttest copied to clipboard

unable to 'POST', session not found issue

Open prashantpawr opened this issue 7 years ago • 0 comments

my test file is :

  • config:

    • testset: "Demonstrate use of extract after creating a person"
    • variable_binds: {'username': '', 'password': ''}
  • test:

    • name: "Authentication using basic auth"
    • url: "/login"
    • auth_username:
    • auth_password: ""
    • expected_status: [200]
    • extract_binds:
      • 'cookies' : { header: 'set-cookie'}
  • test: # create entity by POST

    • name: "Get Dept id"
    • method: "GET"
    • url: "/resource/api/0.1/depts/"
    • auth_username: "
    • auth_password: ""
    • headers: {template: {Content-Type: application/json, 'Set-Cookie': '$cookies'}}
    • expected_status: [200, 201]
    • extract_binds:
      • 'DeptId': {jmespath: "_embedded.depts[?name=='av'].id | [0]"}
  • test:

    • name: "Get project id"
    • method: "GET"
    • url: {'template': "/resource/api/0.1/projects/search/findByDeptId?deptId=$DeptId"}
    • auth_username:
    • auth_password: "
    • headers: {template: {Content-Type: application/json, 'Set-Cookie': '$cookies'}}
    • expected_status: [200, 201]
    • extract_binds:
      • 'ProjectId': {jmespath: "_embedded.projects[?name=='aasdlot-c'].id | [0]"}
  • test:

    • name: 'POST Batch'
    • method: 'POST'
    • url: '/resource/api/0.1/batches'
    • auth_username: "
    • auth_password: "
    • headers: {template: {Content-Type: application/json, 'Set-Cookie': '$cookies'}}
    • body: {template: '{"approved":"false","committed":"false","createdBy":"/resource/api/0.1/users/","project":"/resource/api/0.1/projects/$ProjectId","size":"1","updatedBy":"/resource/api/0.1/users/"}'}

all earlier 3 tests perform well and give success return code bug for the 4th one though i am getting same cookie text as of others, i am not able to perform POST operation giving following error

POST Batch

REQUEST: POST https://acme-4/resource/api/0.1/batches HEADERS: {'Set-Cookie': "['XSRF-TOKEN=0c6f5090-1b18-4f52-8790-9655805f5e08', 'SESSION=4c91b7f6-43a3-49e5-ba2e-0a64613bb335']"}

{"approved":"false","committed":"false","createdBy":"/resource/api/0.1/users/ppawar","project":"/resource/api/0.1/projects/5833dc36fb29d4001bbb2d1d","size":"1","updatedBy":"/resource/api/0.1/users/ppawar"} Press ENTER when ready (0): RESPONSE: {"timestamp":1485967873161,"status":403,"error":"Forbidden","message":"Could not verify the provided CSRF token because your session was not found.","path":"/resource/api/0.1/batches"} RESPONSE HEADERS: [('x-content-type-options', 'nosniff'), ('x-xss-protection', '1; mode=block'), ('cache-control', 'no-cache, no-store, max-age=0, must-revalidate'), ('pragma', 'no-cache'), ('expires', '0'), ('strict-transport-security', 'max-age=31536000 ; includeSubDomains'), ('x-frame-options', 'DENY'), ('set-cookie', 'SESSION=6784b0d2-1ffa-48ae-be61-d143e0e8ea84;path=/;Secure;HttpOnly'), ('content-type', 'application/json;charset=UTF-8'), ('transfer-encoding', 'chunked'), ('date', 'Wed, 01 Feb 2017 16:51:13 GMT'), ('connection', 'close')] ERROR:Test Failed: POST Batch URL=https://acme-4/resource/api/0.1/batches Group=Default HTTP Status Code: 403 ERROR:Test Failure, failure type: Invalid HTTP Response Code, Reason: Invalid HTTP response code: response code 403 not in expected codes [[200, 201, 204]]

========================

what am i missing ??

prashantpawr avatar Feb 01 '17 18:02 prashantpawr