File tree Expand file tree Collapse file tree
google/auth/compute_engine Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838
3939_LOGGER = logging .getLogger (__name__ )
4040
41- _SERVICE_ACCOUNT_EMAIL_PATTERN = re .compile (r"^[^@]+@[^@]+\.[^@]+$" )
41+ _SERVICE_ACCOUNT_EMAIL_PATTERN = re .compile (
42+ r"^[^@]+@[^@]+\.gserviceaccount\.com$" , re .IGNORECASE
43+ )
4244
4345_GCE_DEFAULT_MDS_IP = "169.254.169.254"
4446_GCE_DEFAULT_HOST = "metadata.google.internal"
Original file line number Diff line number Diff line change @@ -993,9 +993,13 @@ def test__is_service_account_email():
993993 _metadata ._is_service_account_email ("my-sa@my-project.iam.gserviceaccount.com" )
994994 is True
995995 )
996- assert _metadata ._is_service_account_email ("test@example.com" ) is True
996+ assert (
997+ _metadata ._is_service_account_email ("my-sa@my-project.iam.GSERVICEACCOUNT.COM" )
998+ is True
999+ )
9971000
9981001 # Empty inputs and standard string placeholders
1002+ assert _metadata ._is_service_account_email ("test@example.com" ) is False
9991003 assert _metadata ._is_service_account_email ("default" ) is False
10001004 assert _metadata ._is_service_account_email ("" ) is False
10011005 assert _metadata ._is_service_account_email (None ) is False
You can’t perform that action at this time.
0 commit comments