def test_set_credentials_gcp(): '''Test GCP credentials creating''' kserve_client = KServeClient() sa_name = constants.DEFAULT_SA_NAME kserve_client.set_credentials( storage_type='gcs', namespace=KSERVE_TEST_NAMESPACE, credentials_file='./credentials/gcp_credentials.json', sa_name=sa_name) created_sa = get_created_sa(sa_name) created_secret_name = created_sa.secrets[0].name created_secret = get_created_secret(created_secret_name) assert created_secret.data[ constants.GCS_CREDS_FILE_DEFAULT_NAME] == gcp_testing_creds
def test_azure_credentials(): '''Test Azure credentials creating''' kserve_client = KServeClient() sa_name = constants.DEFAULT_SA_NAME kserve_client.set_credentials( storage_type='Azure', namespace=KSERVE_TEST_NAMESPACE, credentials_file='./credentials/azure_credentials.json', sa_name=sa_name) created_sa = get_created_sa(sa_name) created_secret_name = created_sa.secrets[0].name created_secret = get_created_secret(created_secret_name) assert created_secret.data['AZ_CLIENT_ID'] == 'dXNlcgo=' assert created_secret.data['AZ_CLIENT_SECRET'] == 'cGFzc3dvcmQ=' assert created_secret.data[ 'AZ_SUBSCRIPTION_ID'] == 'MzMzMzMzMzMtMzMzMy0zMzMzLTMzMzMtMzMzMzMz' assert created_secret.data['AZ_TENANT_ID'] == 'MTIzNAo='
def test_set_credentials_s3(): """Test S3 credentials creating.""" kfserving = KServeClient() credentials_file = './credentials/aws_credentials' # Test creating service account case. sa_name = constants.DEFAULT_SA_NAME if check_sa_exists(sa_name): delete_sa(sa_name) kfserving.set_credentials(storage_type='s3', namespace=KSERVE_TEST_NAMESPACE, credentials_file=credentials_file, s3_profile='default', s3_endpoint='s3.us-west-2.amazonaws.com', s3_region='us-west-2', s3_use_https='1', s3_verify_ssl='0') sa_body = get_created_sa(sa_name) created_secret_name = sa_body.secrets[0].name created_secret = get_created_secret(created_secret_name) config = configparser.ConfigParser() config.read([expanduser(credentials_file)]) s3_access_key_id = config.get('default', 'aws_access_key_id') s3_secret_access_key = config.get('default', 'aws_secret_access_key') assert created_secret.data[ constants.S3_ACCESS_KEY_ID_DEFAULT_NAME] == s3_access_key_id assert created_secret.data[ constants.S3_SECRET_ACCESS_KEY_DEFAULT_NAME] == s3_secret_access_key assert created_secret.metadata.annotations[ constants.KSERVE_GROUP + '/s3-endpoint'] == 's3.us-west-2.amazonaws.com' assert created_secret.metadata.annotations[constants.KSERVE_GROUP + '/s3-region'] == 'us-west-2' assert created_secret.metadata.annotations[constants.KSERVE_GROUP + '/s3-usehttps'] == '1' assert created_secret.metadata.annotations[constants.KSERVE_GROUP + '/s3-verifyssl'] == '0'