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
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
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"
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
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()