Projekt

Obecné

Profil

« Předchozí | Další » 

Revize fbfc4b04

Přidáno uživatelem Michal Seják před téměř 4 roky(ů)

Re #8705 - Reformatting, test updates (discussed invalid branch returns 400).

Zobrazit rozdíly:

tests/integration_tests/rest_api/certificates_test.py
42 42
        usage = ["SSL", "authentication", "digitalSignature"]
43 43

  
44 44
    return server.post("/api/certificates", content_type="application/json", json={
45
    "CA": parent,
46
    "subject": {
47
        "C": "CZ",
48
        "CN": title,
49
        "L": "Pilsen",
50
        "O": title,
51
        "OU": "IT department",
52
        "ST": "Pilsen Region",
53
        "emailAddress": "end@ca.com"
54
    },
55
    "usage": usage,
56
    "validityDays": 30
45
        "CA": parent,
46
        "subject": {
47
            "C": "CZ",
48
            "CN": title,
49
            "L": "Pilsen",
50
            "O": title,
51
            "OU": "IT department",
52
            "ST": "Pilsen Region",
53
            "emailAddress": "end@ca.com"
54
        },
55
        "usage": usage,
56
        "validityDays": 30
57 57
    })
58 58

  
59 59

  
......
703 703

  
704 704

  
705 705
def test_certificate_deletion(server):
706

  
707 706
    # custom tree for checking node bijection w/ the actual certificate tree
708 707
    all_certs = {}
709 708
    parent_of = {}
......
788 787

  
789 788
            # twice, just in case
790 789
            ret = server.get(f"/api/certificates/{cert_id}")
791
            assert ret.status_code == 205   # TODO change to 404 after someone gets the issue assigned and resolves it
790
            assert ret.status_code == 205  # TODO change to 404 after someone gets the issue assigned and resolves it
792 791
            json = ret.json
793 792
            assert "data" in json
794 793
            assert "success" in json
......
910 909
    assert ret.json["success"]
911 910
    assert ret.json["data"]["status"] == "expired"
912 911

  
912

  
913 913
def test_create_with_key_with_pass_valid(server, cryptography_service):
914 914
    key_pass = "123456Seven"
915 915
    key_pem = cryptography_service.create_private_key(key_pass)
......
933 933
    ret = server.post("/api/certificates", content_type="application/json", json=certificate)
934 934
    assert ret.status_code == 201
935 935

  
936

  
936 937
def test_create_with_key_with_pass_invalid_1(server, cryptography_service):
937 938
    key_pass = "123456Seven"
938 939
    key_pem = cryptography_service.create_private_key(key_pass)
......
958 959
    assert ret.json["data"] == 'The provided passphrase does not match the provided key.'
959 960
    assert not ret.json["success"]
960 961

  
962

  
961 963
def test_create_with_key_with_pass_invalid_2(server, cryptography_service):
962 964
    key_pass = "123456Seven"
963 965

  
......
982 984
    assert ret.json["data"] == 'The provided passphrase does not match the provided key.'
983 985
    assert not ret.json["success"]
984 986

  
987

  
985 988
def test_create_with_key_no_pass(server, cryptography_service):
986 989
    key_pem = cryptography_service.create_private_key()
987 990

  
988 991
    certificate = {
989
        "CA": 1,
990 992
        "subject": {
991 993
            "C": "CZ",
992 994
            "CN": "Rare Name",
......
1003 1005
    ret = server.post("/api/certificates", content_type="application/json", json=certificate)
1004 1006
    assert ret.status_code == 201
1005 1007

  
1008

  
1006 1009
def test_create_with_key_no_pass_invalid_1(server, cryptography_service):
1007 1010
    certificate = {
1008
        "CA": 1,
1009 1011
        "subject": {
1010 1012
            "C": "CZ",
1011 1013
            "CN": "Rare Name",
......
1023 1025
    assert ret.status_code == 400
1024 1026
    assert not ret.json["success"]
1025 1027

  
1028

  
1026 1029
def test_create_no_key_with_pass(server, cryptography_service):
1027 1030
    key_pass = "123456Seven"
1028 1031

  
......
1051 1054
    key_pem = ret.json["data"]
1052 1055
    assert cryptography_service.verify_key(key_pem, key_pass)
1053 1056

  
1057

  
1054 1058
def test_create_no_key_with_pass_invalid_1(server, cryptography_service):
1055 1059
    key_pass = "123456Seven"
1056 1060

  
......
1079 1083
    key_pem = ret.json["data"]
1080 1084
    assert not cryptography_service.verify_key(key_pem, "iforgotthepassagainimsorryfrowningface")
1081 1085

  
1086

  
1082 1087
def test_create_no_key_no_pass_invalid(server, cryptography_service):
1083 1088
    certificate = {
1084 1089
        "CA": 1,
......
1095 1100
        }
1096 1101
    }
1097 1102
    ret = server.post("/api/certificates", content_type="application/json", json=certificate)
1098
    assert ret.status_code == 201
1103
    assert ret.status_code == 400

Také k dispozici: Unified diff