Esempio n. 1
0
def test_tenant_normalize_slug_invalid() -> None:
    empty_slug = "  "
    with raises(ValueError):
        Tenant._normalize_slug(empty_slug)

    unsupported_slug = " あ "
    with raises(ValueError):
        resp = Tenant._normalize_slug(unsupported_slug)
Esempio n. 2
0
async def test_access_service_generate_token(access_service) -> None:
    tenant = Tenant(id='T1', name='Default')
    user = User(id='U1', username='******', email='johndoe')
    dominion = Dominion(id='D1', name='Data Server')

    token = await access_service.generate_token(tenant, user, dominion)

    assert isinstance(token, Token)
def test_verification_service_generate_token_tenant(
        verification_service) -> None:
    tenant = Tenant(id='1', name='Default', email='*****@*****.**')

    token = verification_service.generate_token_tenant(tenant, 'reset')

    assert isinstance(token, Token)
    assert token.value == ('{"type": "reset", "tenant": "default", '
                           '"tid": "1", "temail": "*****@*****.**"}')
Esempio n. 4
0
def test_tenant_attributes_from_dict() -> None:
    tenant_dict = {
        "id": "farbo007",
        "name": "Hortofrutícola El Cariño",
    }

    tenant = Tenant(**tenant_dict)

    for key, value in tenant_dict.items():
        assert getattr(tenant, key) == value
def test_verification_service_generate_token(verification_service) -> None:
    tenant = Tenant(id='1', name='Default', email='*****@*****.**')
    user = User(id='1', username='******', email='johndoe')

    token = verification_service.generate_token(tenant, user, 'activation')

    assert isinstance(token, Token)
    assert token.value == (
        '{"type": "activation", "tenant": "default", '
        '"tid": "1", "uid": "1", "temail": "*****@*****.**"}')
Esempio n. 6
0
async def test_access_service_generate_token_payload(access_service) -> None:
    tenant = Tenant(id='T1', name='Default')
    user = User(id='U1', username='******', name="John Doe", email='johndoe')
    dominion = Dominion(id='D1', name='Data Server')

    token = await access_service.generate_token(tenant, user, dominion)

    assert token.value == json.dumps({
        "tid": "T1",
        "tenant": "default",
        "organization": "Default",
        "uid": "U1",
        "username": "******",
        "name": "John Doe",
        "email": "johndoe",
        "attributes": {},
        "roles": []
    })
Esempio n. 7
0
def tenant() -> Tenant:
    return Tenant(id='001', name="Amazon")
Esempio n. 8
0
def test_tenant_normalize_slug() -> None:
    given_slug = "Hortofrutícola El Cariño"
    slug = Tenant._normalize_slug(given_slug)

    assert slug == 'hortofruticola_el_carino'