def test_get_api_key_details_by_prefix_bad_values(): with pytest.raises(InvalidStripeAPIKey): get_api_key_details_by_prefix("pk_a") with pytest.raises(InvalidStripeAPIKey): get_api_key_details_by_prefix("sk_a") with pytest.raises(InvalidStripeAPIKey): get_api_key_details_by_prefix("rk_nope_1234")
def test_get_api_key_details_by_prefix_bad_values(): with pytest.raises(ValueError): get_api_key_details_by_prefix("pk_a") with pytest.raises(ValueError): get_api_key_details_by_prefix("sk_a") with pytest.raises(ValueError): get_api_key_details_by_prefix("rk_nope_1234")
def test_get_api_key_details_by_prefix(): assert get_api_key_details_by_prefix(SK_TEST) == (APIKeyType.secret, False) assert get_api_key_details_by_prefix(SK_LIVE) == (APIKeyType.secret, True) assert get_api_key_details_by_prefix(RK_TEST) == (APIKeyType.restricted, False) assert get_api_key_details_by_prefix(RK_LIVE) == (APIKeyType.restricted, True) assert get_api_key_details_by_prefix(PK_TEST) == (APIKeyType.publishable, False) assert get_api_key_details_by_prefix(PK_LIVE) == (APIKeyType.publishable, True)
def test_get_api_key_details_by_prefix(): # avoid literal api keys to prevent git secret scanners false-positives assert get_api_key_details_by_prefix("sk_test_" + "XXXXXXXXXXXXXXXXXXXX1234") == ( APIKeyType.secret, False, ) assert get_api_key_details_by_prefix("sk_live_" + "XXXXXXXXXXXXXXXXXXXX1234") == ( APIKeyType.secret, True, ) assert get_api_key_details_by_prefix( "rk_test_" + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9876") == (APIKeyType.restricted, False) assert get_api_key_details_by_prefix( "rk_live_" + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9876") == (APIKeyType.restricted, True) assert get_api_key_details_by_prefix( "pk_test_" + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAA") == (APIKeyType.publishable, False) assert get_api_key_details_by_prefix( "pk_live_" + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXBBBB") == (APIKeyType.publishable, True)