Пример #1
0
def guess_header(
    headers: requests.Headers, imaginary_user: models.ImaginaryUser,
    db: saSession
) -> Callable[[Set[Union[str, None]], models.ImaginaryUser, saSession],
              JSONResponse]:
    local_session_discoveries = json.loads(
        imaginary_user.imaginary_discoveries)
    if len(set(local_session_discoveries["imaginary_discoveries"])) >= len(
            set(headers.keys())):
        return helper.return_json(
            {"detail": "requests were the same :rooFrozen:"})

    check = set(set(local_session_discoveries["imaginary_discoveries"])) ^ set(
        headers.keys())

    return _submit_attempt(check, imaginary_user, db)
Пример #2
0
def test_invalid_certificate_response_untrusted(
        untrusted_cert_b64: str) -> None:
    resp = _invalid_certificate_response(
        Headers(headers={"certificate": untrusted_cert_b64}))
    assert resp
    assert resp.status_code == 401
    assert resp.body == b'{"detail":"Client certificate not trusted"}'
Пример #3
0
 def get_bearer_token(params: dict, headers: requests.Headers):
     login_info = params.get("login_info", {}) or {}
     auth_key = staff_key
     if "provider" in login_info:
         auth_key = "g_authorization"
     authorization = headers.get(auth_key) or ""
     bearer_token = authorization.replace("Bearer", "").strip()
     return bearer_token
Пример #4
0
def test_invalid_certificate_response_malformed() -> None:
    resp = _invalid_certificate_response(Headers(headers={"certificate": "let me in!"}))
    assert resp
    assert resp.status_code == 400
    assert resp.body == b'{"detail":"Client certificate deserialization: base64 decoding failed"}'
Пример #5
0
def test_invalid_certificate_response_missing() -> None:
    resp = _invalid_certificate_response(Headers(headers={}))
    assert resp
    assert resp.status_code == 400
    assert resp.body == b'{"detail":"Client certificate missing in header"}'
Пример #6
0
def test_invalid_certificate_response_ok(trusted_cert_b64: str) -> None:
    assert _invalid_certificate_response(Headers(headers={"certificate": trusted_cert_b64})) is None