示例#1
0
 def test_expire_missing_secret(self, client):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     resp = client.post(
         "/expire_response",
         data={"name": "example.com"},
     )
     assert resp.status_code == 400
示例#2
0
 def test_expire_wrong_secret(self, client):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     resp = client.post(
         "/expire_response",
         data={
             "name": "example.com",
             "secret": "wrong_secret"
         },
     )
     assert resp.status_code == 403
     assert resp.json()["result"] is False
示例#3
0
 def test_expire_response_mixed_case(self, client):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     resp = client.post(
         "/expire_response",
         data={
             "name": "exAMple.Com",
             "secret": "test_secret"
         },
     )
     assert resp.status_code == 200
     assert resp.json()["result"]["authorisation"] == "example.com"
示例#4
0
 def test_query(self, monkeypatch, test_input, output):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     out = StringIO()
     monkeypatch.setattr(
         "sys.stdin",
         StringIO(test_input),
     )
     monkeypatch.setattr("time.time", lambda: 1592267735)
     with pytest.raises(SystemExit):
         call_command("pipeapi", stdout=out)
     assert out.getvalue() == output
示例#5
0
 def test_successful_list(self):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     out = StringIO()
     call_command("listresponses", stdout=out)
     assert "example.com" in out.getvalue()