コード例 #1
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
コード例 #2
0
def test_update_private_key(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    private_key = get_resource_filepath("key/private_key.pem",
                                        as_text=False).read_text()
    config.bot.private_key.content = private_key
    assert config.bot.private_key._content == private_key
    assert config.bot.private_key._path is None
async def test_client_cert_configured_for_app(config):
    client_cert_path = get_resource_filepath("cert/megabot.pem", as_text=True)

    config.app.certificate.path = client_cert_path
    client_factory = ApiClientFactory(config)

    assert client_factory.get_app_session_auth_client(
    ).configuration.cert_file == client_cert_path
コード例 #4
0
async def test_update_avatar(user_api, user_service):
    user_api.v1_admin_user_uid_avatar_update_post = AsyncMock()

    await user_service.update_avatar(1234, "image_string")
    user_api.v1_admin_user_uid_avatar_update_post.assert_called_with(
        uid=1234,
        payload=AvatarUpdate(image="image_string"),
        session_token="session_token")

    with open(get_resource_filepath("user/FINOS_icon_rgb.png", as_text=True),
              "rb") as file:
        avatar_bytes = file.read()
        await user_service.update_avatar(1234, avatar_bytes)

        user_api.v1_admin_user_uid_avatar_update_post.assert_called_with(
            uid=1234,
            payload=AvatarUpdate(
                image=str(base64.standard_b64encode(avatar_bytes))),
            session_token="session_token")
コード例 #5
0
def test_create_signed_jwt_from_path(key_config):
    key_config.path = get_resource_filepath("key/private_key.pem")

    assert create_signed_jwt(key_config, "test_bot") is not None
コード例 #6
0
def test_update_certificate(simple_config_path):
    config = BdkConfigLoader.load_from_file(simple_config_path)
    certificate_path = get_resource_filepath("cert/certificate.cert",
                                             as_text=True)
    config.bot.certificate.path = certificate_path
    assert config.bot.certificate._path == certificate_path