예제 #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()