Exemple #1
0
def test_validate_jwt(jwt_payload):
    signed_jwt = create_signed_jwt_with_claims(
        get_resource_content("key/private_key_from_cert.pem"), jwt_payload)

    claims = validate_jwt(
        signed_jwt,
        get_resource_content("cert/certificate_from_private_key.cert"),
        AUDIENCE)
    assert claims == jwt_payload
Exemple #2
0
def test_validate_jwt_with_wrong_audience(jwt_payload):
    signed_jwt = create_signed_jwt_with_claims(
        get_resource_content("key/private_key_from_cert.pem"), jwt_payload)

    with pytest.raises(InvalidAudienceError):
        validate_jwt(
            signed_jwt,
            get_resource_content("cert/certificate_from_private_key.cert"),
            "wrong audience")
Exemple #3
0
def test_create_signed_jwt(key_config):
    key_config.content = get_resource_content("key/private_key.pem")
    key_config.path = get_resource_filepath("key/private_key.pem")

    assert key_config._content is None
    assert key_config._path is not None
    assert create_signed_jwt(key_config, "test_bot") is not None
Exemple #4
0
async def test_retrieve_datafeed_from_invalid_datafeed_dir(
        tmpdir, datafeed_api, auth_session, config, read_df_side_effect):
    datafeed_id_file_content = get_resource_content("datafeed/datafeedId")
    datafeed_id_file_path = tmpdir.join("datafeed.id")
    datafeed_id_file_path.write(datafeed_id_file_content)

    datafeed_config = BdkDatafeedConfig({"idFilePath": str(tmpdir)})
    config.datafeed = datafeed_config

    datafeed_loop = auto_stopping_datafeed_loop_v1(datafeed_api, auth_session,
                                                   config)
    datafeed_api.v4_datafeed_id_read_get.side_effect = read_df_side_effect
    await datafeed_loop.start()

    assert datafeed_loop._datafeed_id == "8e7c8672-220"
Exemple #5
0
def test_validate_jwt_with_invalid_jwt():
    with pytest.raises(AuthInitializationError):
        validate_jwt(
            "invalid jwt",
            get_resource_content("cert/certificate_from_private_key.cert"),
            AUDIENCE)
Exemple #6
0
def test_validate_jwt_with_invalid_cert(jwt_payload):
    with pytest.raises(AuthInitializationError):
        signed_jwt = create_signed_jwt_with_claims(
            get_resource_content("key/private_key_from_cert.pem"), jwt_payload)
        validate_jwt(signed_jwt, "invalid cert content", AUDIENCE)
Exemple #7
0
def test_create_signed_jwt_from_content(key_config):
    key_config.content = get_resource_content("key/private_key.pem")

    assert create_signed_jwt(key_config, "test_bot") is not None
Exemple #8
0
def fixture_message_with_data():
    return create_v4_message("<div data-format=\"PresentationML\" data-version=\"2.0\"> \n" \
                             "<a href=\"http://www.symphony.com\">This is a link to Symphony's Website</a> \n </div>",
                             get_resource_content("utils/message_entity_data.json"))
def fixture_message():
    message = MagicMock(V4Message)
    message.data = get_resource_content("utils/message_entity_data.json")
    message.message = "<div data-format=\"PresentationML\" data-version=\"2.0\"> \n" \
                      "<a href=\"http://www.symphony.com\">This is a link to Symphony's Website</a> \n </div>"
    return message