{"action":"created","issue":{"url":"https://api.github.com/repos/svanoort/pyresttest/issues/35","labels_url":"https://api.github.com/repos/svanoort/pyresttest/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/svanoort/pyresttest/issues/35/comments","events_url":"https://api.github.com/repos/svanoort/pyresttest/issues/35/events","html_url":"https://github.com/svanoort/pyresttest/issues/35","id":57590707,"number":35,"title":"Issue with Basic Auth or Package Installation","user":{"login":"wadeaa","id":9549857,"avatar_url":"https://avatars.githubusercontent.com/u/9549857?v=3","gravatar_id":"","url":"https://api.github.com/users/wadeaa","html_url":"https://github.com/wadeaa","followers_url":"https://api.github.com/users/wadeaa/followers","following_url":"https://api.github.com/users/wadeaa/following{/other_user}","gists_url":"https://api.github.com/users/wadeaa/gists{/gist_id}","starred_url":"https://api.github.com/users/wadeaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wadeaa/subscriptions","organizations_url":"https://api.github.com/users/wadeaa/orgs","repos_url":"https://api.github.com/users/wadeaa/repos","events_url":"https://api.github.com/users/wadeaa/events{/privacy}","received_events_url":"https://api.github.com/users/wadeaa/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"svanoort","id":5400948,"avatar_url":"https://avatars.githubusercontent.com/u/5400948?v=3","gravatar_id":"","url":"https://api.github.com/users/svanoort","html_url":"https://github.com/svanoort","followers_url":"https://api.github.com/users/svanoort/followers","following_url":"https://api.github.com/users/svanoort/following{/other_user}","gists_url":"https://api.github.com/users/svanoort/gists{/gist_id}","starred_url":"https://api.github.com/users/svanoort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svanoort/subscriptions","organizations_url":"https://api.github.com/users/svanoort/orgs","repos_url":"https://api.github.com/users/svanoort/repos","events_url":"https://api.github.com/users/svanoort/events{/privacy}","received_events_url":"https://api.github.com/users/svanoort/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-02-13T11:56:54Z","updated_at":"2015-02-16T12:03:27Z","closed_at":"2015-02-16T12:03:27Z","body":"Hi, \r\nI installed your package as per your readme instructions and after running through the quickstart I started to play with my own API - a call to a Basic Auth secured function using the following YAML:\r\n\r\n---\r\n- config:\r\n   - testset: \"API session function Test\"\r\n\r\n- test:\r\n   - group: \"Session\"\r\n   - name: \"Get /session/\"\r\n   - url: \"/api/session/\"\r\n   - auth_username: \"wade.a.a@googlemail.com\"\r\n   - auth_password: \"pass\"\r\n   - expected_status: [200]\r\n\r\nRunning with the command 'resttest.py http://10.1.1.84:80 apitest2.yaml --log debug --interactive true --print-bodies true' gives the following:\r\n\r\n===================================\r\nGet /session/\r\n-----------------------------------\r\nREQUEST:\r\nGET http://10.1.1.84:80/api/session/\r\nPress ENTER when ready: \r\nDEBUG:Initial Test Result, based on expected response code: False\r\nRESPONSE:\r\nUnauthorized Access\r\nDEBUG:{\"test\": {\"expected_status\": [200], \"_headers\": {}, \"group\": \"Session\", \"name\": \"Get /session/\", \"_url\": \"http://10.1.1.84:80/api/session/\", \"templated\": {}}, \"failures\": [{\"failure_type\": \"Invalid HTTP Response Code\", \"message\": \"Invalid HTTP response code: response code 401 not in expected codes [[200]]\", \"validator\": null, \"details\": null}], \"response_code\": 401, \"body\": \"Unauthorized Access\", \"passed\": false}\r\nERROR:Test Failed: Get /session/ URL=http://10.1.1.84:80/api/session/ Group=Session HTTP Status Code: 401\r\nERROR:Test Failure, failure type: Invalid HTTP Response Code, Reason: Invalid HTTP response code: response code 401 not in expected codes [[200]]\r\n===================================\r\nTest Group Session FAILED: 0/1 Tests Passed!\r\n\r\nNo sign of the auth info in the data. So I had a look at the code, got confused as it seemed fine then ran the resttest.py script directly in python (after adding the line 'print \"AUTH: %s:%s\" % (mytest.auth_username, mytest.auth_password)' at line 268 in /pyrestest/resttest.py) to get the following:\r\n\r\n===================================\r\nGet /session/\r\n-----------------------------------\r\nREQUEST:\r\nGET http://10.1.1.84:80/api/session/\r\nAUTH: wade.a.a@googlemail.com:pass\r\nPress ENTER when ready: \r\nDEBUG:Initial Test Result, based on expected response code: True\r\nDEBUG:no validators found\r\nRESPONSE:\r\n{\r\n  \"duration\": 43200, \r\n  \"friendly_name\": \"A Wade\", \r\n  \"token\": \"eyJhbGciOiJIUzI1NiIsImV4cCI6MTQyMzg2OTk4NCwiaWF0IjoxNDIzODI2Nzg0fQ.eyJlbWFpbCI6ImFyY2hpZS53YWRlQGFyaWEtbmV0d29ya3MuY29tIn0.NaoVU3gM-JDEy162R1TcBpZgzkpgmsGwqryJTSpm1rI\"\r\n}\r\nDEBUG:{\"body\": \"{\\n  \\\"duration\\\": 43200, \\n  \\\"friendly_name\\\": \\\"A Wade\\\", \\n  \\\"token\\\": \\\"eyJhbGciOiJIUzI1NiIsImV4cCI6MTQyMzg2OTk4NCwiaWF0IjoxNDIzODI2Nzg0fQ.eyJlbWFpbCI6ImFyY2hpZS53YWRlQGFyaWEtbmV0d29ya3MuY29tIn0.NaoVU3gM-JDEy162R1TcBpZgzkpgmsGwqryJTSpm1rI\\\"\\n}\", \"response_headers\": {\"content-length\": \"235\", \"expires\": \"Fri, 13 Feb 2015 11:26:23 GMT\", \"server\": \"nginx/1.4.6 (Ubuntu)\", \"connection\": \"close\", \"pragma\": \"no-cache\", \"cache-control\": \"no-cache\", \"date\": \"Fri, 13 Feb 2015 11:26:24 GMT\", \"content-type\": \"application/json\"}, \"response_code\": 200, \"passed\": true, \"test\": {\"expected_status\": [200], \"_headers\": {}, \"group\": \"Session\", \"name\": \"Get /session/\", \"_url\": \"http://10.1.1.84:80/api/session/\", \"templated\": {}, \"auth_password\": \"pass\", \"auth_username\": \"wade.a.a@googlemail.com\"}, \"failures\": []}\r\nINFO:Test Succeeded: Get /session/ URL=http://10.1.1.84:80/api/session/ Group=Session\r\n===================================\r\nTest Group Session SUCCEEDED: 1/1 Tests Passed!\r\n\r\nWhich is what I expected originally. So why would the Auth work fine on one run through but not the other? I suspect the install is pointing to an older version of the script somehow, but I don't know enough to prove that.\r\n\r\nAlso, running the test:\r\n\r\n- test:\r\n   - group: \"Session\"\r\n   - name: \"Put /session/\"\r\n   - url: \"/api/session/\"\r\n   - method: \"PUT\"\r\n   - auth_username: \"wade.a.a@googlemail.com\"\r\n   - auth_password: \"pass\"\r\n   - expected_status: [200]\r\n\r\n \r\nLeads to :\r\nTraceback (most recent call last):\r\n  File \"resttest.py\", line 720, in <module>\r\n    command_line_run(sys.argv[1:])\r\n  File \"resttest.py\", line 716, in command_line_run\r\n    main(args)\r\n  File \"resttest.py\", line 685, in main\r\n    failures = run_testsets(tests)\r\n  File \"resttest.py\", line 547, in run_testsets\r\n    result = run_test(test, test_config = myconfig, context=context)\r\n  File \"resttest.py\", line 250, in run_test\r\n    curl = templated_test.configure_curl(timeout=test_config.timeout, context=my_context)\r\n  File \"/home/archie/Projects/APITesting/pyresttest/pyresttest/tests.py\", line 264, in configure_curl\r\n    curl.setopt(curl.READFUNCTION, StringIO(bod).read)\r\nTypeError: must be string or buffer, not None\r\n\r\npresumably because of (intentional but perhaps misguided) lack of a body in the PUT call.\r\n\r\nI really like the package though, it will be very useful in the future, so thank you very much for building it and putting it up here.\r\n\r\nCheers,\r\nWade\r\n\r\n\r\n\r\n \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/svanoort/pyresttest/issues/comments/74498843","html_url":"https://github.com/svanoort/pyresttest/issues/35#issuecomment-74498843","issue_url":"https://api.github.com/repos/svanoort/pyresttest/issues/35","id":74498843,"user":{"login":"svanoort","id":5400948,"avatar_url":"https://avatars.githubusercontent.com/u/5400948?v=3","gravatar_id":"","url":"https://api.github.com/users/svanoort","html_url":"https://github.com/svanoort","followers_url":"https://api.github.com/users/svanoort/followers","following_url":"https://api.github.com/users/svanoort/following{/other_user}","gists_url":"https://api.github.com/users/svanoort/gists{/gist_id}","starred_url":"https://api.github.com/users/svanoort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svanoort/subscriptions","organizations_url":"https://api.github.com/users/svanoort/orgs","repos_url":"https://api.github.com/users/svanoort/repos","events_url":"https://api.github.com/users/svanoort/events{/privacy}","received_events_url":"https://api.github.com/users/svanoort/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T12:03:27Z","updated_at":"2015-02-16T12:03:27Z","body":"Hi Wade, \r\nI'm glad that cleared up the issue for you!  In the future I'll try to keep code merges and PyPi releases in closer step to avoid this sort of issue. \r\n\r\nThanks,\r\nSam"}}