@@ -854,7 +854,7 @@ public void fromJSON_noUniverseDomain() throws IOException {
854854 }
855855
856856 @ Test
857- public void fromJSON_UniverseDomain () throws IOException {
857+ public void fromJSON_UniverseDomainSet () throws IOException {
858858 GenericJson json =
859859 writeServiceAccountJson (
860860 SA_CLIENT_ID ,
@@ -875,7 +875,39 @@ public void fromJSON_UniverseDomain() throws IOException {
875875 }
876876
877877 @ Test
878- public void getUniverseDomain_defaultUniverse () throws IOException {
878+ public void fromPkcs8_DefaultUniverseDomain () throws IOException {
879+ ServiceAccountJwtAccessCredentials credentials =
880+ ServiceAccountJwtAccessCredentials .fromPkcs8 (
881+ SA_CLIENT_ID , SA_CLIENT_EMAIL , SA_PRIVATE_KEY_PKCS8 , SA_PRIVATE_KEY_ID );
882+ assertEquals (SA_CLIENT_ID , credentials .getClientId ());
883+ assertEquals (SA_CLIENT_EMAIL , credentials .getClientEmail ());
884+ assertEquals (
885+ OAuth2Utils .privateKeyFromPkcs8 (SA_PRIVATE_KEY_PKCS8 ), credentials .getPrivateKey ());
886+ assertNull (credentials .getQuotaProjectId ());
887+ assertEquals (GOOGLE_DEFAULT_UNIVERSE , credentials .getUniverseDomain ());
888+ }
889+
890+ @ Test
891+ public void fromPkcs8_CustomUniverseDomain () throws IOException {
892+ ServiceAccountJwtAccessCredentials credentials =
893+ ServiceAccountJwtAccessCredentials .fromPkcs8 (
894+ SA_CLIENT_ID ,
895+ SA_CLIENT_EMAIL ,
896+ SA_PRIVATE_KEY_PKCS8 ,
897+ SA_PRIVATE_KEY_ID ,
898+ URI .create ("default-aud" ),
899+ QUOTA_PROJECT ,
900+ "example.com" );
901+ assertEquals (SA_CLIENT_ID , credentials .getClientId ());
902+ assertEquals (SA_CLIENT_EMAIL , credentials .getClientEmail ());
903+ assertEquals (
904+ OAuth2Utils .privateKeyFromPkcs8 (SA_PRIVATE_KEY_PKCS8 ), credentials .getPrivateKey ());
905+ assertEquals (QUOTA_PROJECT , credentials .getQuotaProjectId ());
906+ assertEquals ("example.com" , credentials .getUniverseDomain ());
907+ }
908+
909+ @ Test
910+ public void builder_defaultUniverseDomain () throws IOException {
879911 PrivateKey privateKey = OAuth2Utils .privateKeyFromPkcs8 (SA_PRIVATE_KEY_PKCS8 );
880912 ServiceAccountJwtAccessCredentials credentials =
881913 ServiceAccountJwtAccessCredentials .newBuilder ()
@@ -889,7 +921,7 @@ public void getUniverseDomain_defaultUniverse() throws IOException {
889921 }
890922
891923 @ Test
892- public void getUniverseDomain_customUniverse () throws IOException {
924+ public void builder_customUniverseDomain () throws IOException {
893925 PrivateKey privateKey = OAuth2Utils .privateKeyFromPkcs8 (SA_PRIVATE_KEY_PKCS8 );
894926 ServiceAccountJwtAccessCredentials credentials =
895927 ServiceAccountJwtAccessCredentials .newBuilder ()
0 commit comments