Esempio n. 1
0
 def test_expire_missing_secret(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/expire_authorisation",
         data={"name": "example.com"},
     )
     assert resp.status_code == 400
Esempio n. 2
0
 def test_expire_missing_name(self, client):
     create_authorisation(name="example.com")
     create_response(name="example.com")
     resp = client.post(
         "/expire_response",
         data={"secret": "test_secret"},
     )
     assert resp.status_code == 400
Esempio n. 3
0
 def test_publish_missing_secret(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/publish_response",
         data={
             "name": "example.com",
             "response": "random_secret"
         },
     )
     assert resp.status_code == 400
Esempio n. 4
0
 def test_expire_mixed_case(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/expire_authorisation",
         data={
             "name": "exAMplE.cOm",
             "secret": "test_secret"
         },
     )
     assert resp.status_code == 200
     assert resp.json()["result"]["authorisation"] == "example.com"
Esempio n. 5
0
 def test_expire_wrong_secret(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/expire_authorisation",
         data={
             "name": "example.com",
             "secret": "wrong_secret"
         },
     )
     assert resp.status_code == 403
     assert resp.json()["result"] is False
Esempio n. 6
0
 def test_publish_wrong_secret(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/publish_response",
         data={
             "name": "example.com",
             "response": "random_secret",
             "secret": "wrong_secret",
         },
     )
     assert resp.status_code == 403
     assert resp.json()["result"] is False
Esempio n. 7
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
Esempio n. 8
0
 def test_publish_response_mixed_case(self, client):
     create_authorisation(name="example.com")
     resp = client.post(
         "/publish_response",
         data={
             "name": "exAMple.coM",
             "response": "random_secret",
             "secret": "test_secret",
         },
     )
     assert resp.status_code == 200
     assert resp.json()["result"]["authorisation"] == "example.com"
     assert resp.json()["result"]["published"] is True
Esempio n. 9
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()
Esempio n. 10
0
 def test_mixed_case(self):
     create_authorisation(name="example.com")
     out = StringIO()
     call_command("deleteauthorisation", "eXAmple.cOm", stdout=out)
     assert Authorisation.objects.count() == 0
Esempio n. 11
0
 def test_no_domain_matched_name(self):
     create_authorisation(name="example.com")
     out = StringIO()
     with pytest.raises(CommandError):
         call_command("deleteauthorisation", "example.org", stdout=out)
Esempio n. 12
0
 def test_successful_delete(self):
     create_authorisation(name="example.com")
     out = StringIO()
     call_command("deleteauthorisation", "example.com", stdout=out)
     assert Authorisation.objects.count() == 0