Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 977845e0

Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)

Re #8708 - Changed /api/certificates/{id}/identity endpoint method back to POST (facepalm)

Changed REST API tests accordingly.

Zobrazit rozdíly:

app.py
85 85
    return crl_ocsp_controller.get_ocsp_from_der(id, request.data)
86 86

  
87 87

  
88
@app.route('/api/certificates/<id>/identity', methods=["GET"])
88
@app.route('/api/certificates/<id>/identity', methods=["POST"])
89 89
def generate_certificate_pkcs_identity(id, certificate_controller: CertController):
90 90
    return certificate_controller.generate_certificate_pkcs_identity(id)
91 91

  
src/swagger.yaml
367 367
              schema:
368 368
                $ref: '#/components/schemas/ErrorResponse'
369 369
  /api/certificates/{id}/identity:
370
    get:
370
    post:
371 371
      tags:
372 372
      - certificates
373 373
      summary: Create a PCKS12 identity
tests/integration_tests/rest_api/certificates_test.py
953 953
        "name": "Foo Identity",
954 954
        "password": "foobarbaz"
955 955
    }
956
    identity_ret = server.get(f"/api/certificates/{ret.json['data']}/identity", content_type="application/json",
957
                              json=identity_details)
956
    identity_ret = server.post(f"/api/certificates/{ret.json['data']}/identity", content_type="application/json",
957
                               json=identity_details)
958 958

  
959 959
    # assert valid HTTP status code and correct content type
960 960
    assert identity_ret.status_code == 200
......
963 963

  
964 964
def test_generate_identity_non_well_formed(server):
965 965
    # non integer ID
966
    identity_ret = server.get(f"/api/certificates/foo/identity", content_type="application/json",
967
                              json={})
966
    identity_ret = server.post(f"/api/certificates/foo/identity", content_type="application/json",
967
                               json={})
968 968
    assert identity_ret.status_code == 400
969 969

  
970 970
    # required fields not passed
971
    identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json",
972
                              json={})
971
    identity_ret = server.post(f"/api/certificates/0/identity", content_type="application/json",
972
                               json={})
973 973
    assert identity_ret.status_code == 400
974 974
    assert identity_ret.json == E_IDENTITY_NAME_NOT_SPECIFIED
975 975

  
976 976
    # passphrase not passed
977
    identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json",
978
                              json={"name": "Foo"})
977
    identity_ret = server.post(f"/api/certificates/0/identity", content_type="application/json",
978
                               json={"name": "Foo"})
979 979
    assert identity_ret.status_code == 400
980 980
    assert identity_ret.json == E_IDENTITY_PASSWORD_NOT_SPECIFIED
981 981

  
982 982
    # name not passed
983
    identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json",
984
                              json={"password": "foopass"})
983
    identity_ret = server.post(f"/api/certificates/0/identity", content_type="application/json",
984
                               json={"password": "foopass"})
985 985
    assert identity_ret.status_code == 400
986 986
    assert identity_ret.json == E_IDENTITY_NAME_NOT_SPECIFIED
987 987

  
988 988
    # certificate not existing
989
    identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json",
990
                              json={"password": "foopass", "name": "Foo"})
989
    identity_ret = server.post(f"/api/certificates/0/identity", content_type="application/json",
990
                               json={"password": "foopass", "name": "Foo"})
991 991
    assert identity_ret.status_code == 404
992 992
    assert identity_ret.json == E_NO_CERTIFICATES_FOUND

Také k dispozici: Unified diff