def test_user_app_token_auth(): token = "123456446" user_kcsb = KustoConnectionStringBuilder.with_aad_user_token_authentication( KUSTO_TEST_URI, token) app_kcsb = KustoConnectionStringBuilder.with_aad_application_token_authentication( KUSTO_TEST_URI, token) user_helper = _AadHelper(user_kcsb) app_helper = _AadHelper(app_kcsb) auth_header = user_helper.acquire_authorization_header() assert auth_header.index(token) > -1 auth_header = app_helper.acquire_authorization_header() assert auth_header.index(token) > -1
def test_aad_user_token(self): """Checks kcsb that is created with AAD user token.""" token = "The user hardest token ever" kcsb = KustoConnectionStringBuilder.with_aad_user_token_authentication( "localhost", user_token=token) assert kcsb.data_source == "localhost" assert kcsb.user_token == token assert kcsb.aad_federated_security assert kcsb.aad_user_id is None assert kcsb.password is None assert kcsb.application_client_id is None assert kcsb.application_key is None assert kcsb.application_token is None assert kcsb.authority_id == "common" assert repr( kcsb ) == "Data Source=localhost;AAD Federated Security=True;Authority Id=common;User Token=%s" % token assert str( kcsb ) == "Data Source=localhost;AAD Federated Security=True;Authority Id=common;User Token=%s" % self.PASSWORDS_REPLACEMENT
def proxy_kcsb(request) -> Tuple[KustoConnectionStringBuilder, bool]: cluster = KustoClientTestsMixin.HOST user = "******" password = "******" authority_id = "13456" uuid = "11111111-1111-1111-1111-111111111111" key = "key of application" token = "The app hardest token ever" return { "user_password": (KustoConnectionStringBuilder.with_aad_user_password_authentication( cluster, user, password, authority_id), True), "application_key": (KustoConnectionStringBuilder.with_aad_application_key_authentication( cluster, uuid, key, "microsoft.com"), True), "application_token": (KustoConnectionStringBuilder. with_aad_application_token_authentication( cluster, application_token=token), False), "device": (KustoConnectionStringBuilder.with_aad_device_authentication(cluster), True), "user_token": (KustoConnectionStringBuilder.with_aad_user_token_authentication( cluster, user_token=token), False), "managed_identity": (KustoConnectionStringBuilder. with_aad_managed_service_identity_authentication(cluster), False), "token_provider": (KustoConnectionStringBuilder.with_token_provider( cluster, lambda x: x), False), "async_token_provider": (KustoConnectionStringBuilder.with_async_token_provider( cluster, lambda x: x), False), "az_cli": (KustoConnectionStringBuilder.with_az_cli_authentication(cluster), True), "interactive_login": (KustoConnectionStringBuilder.with_interactive_login(cluster), True), }[request.param]