2021-04-22 22:56:30 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2021-07-14 20:02:48 -07:00
|
|
|
@pytest.mark.integration
|
2021-04-22 22:56:30 +02:00
|
|
|
def test_strip_ldap_info():
|
2021-07-14 20:02:48 -07:00
|
|
|
from datahub.ingestion.source.ldap import strip_ldap_info
|
|
|
|
|
2021-04-22 22:56:30 +02:00
|
|
|
assert (
|
|
|
|
strip_ldap_info(b"uid=firstname.surname,ou=People,dc=internal,dc=machines")
|
|
|
|
== "firstname.surname"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-07-14 20:02:48 -07:00
|
|
|
@pytest.mark.integration
|
2021-04-22 22:56:30 +02:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"input, expected",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
{
|
|
|
|
"admins": [
|
|
|
|
b"uid=A.B,ou=People,dc=internal,dc=machines",
|
|
|
|
b"uid=C.D,ou=People,dc=internal,dc=machines",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
["urn:li:corpuser:A.B", "urn:li:corpuser:C.D"],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
{
|
|
|
|
"not_admins": [
|
|
|
|
b"doesntmatter",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_parse_from_attrs(input, expected):
|
2021-07-14 20:02:48 -07:00
|
|
|
from datahub.ingestion.source.ldap import parse_from_attrs
|
|
|
|
|
2021-04-22 22:56:30 +02:00
|
|
|
assert (
|
|
|
|
parse_from_attrs(
|
|
|
|
input,
|
|
|
|
"admins",
|
|
|
|
)
|
|
|
|
== expected
|
|
|
|
)
|