1919
2020public final class TestUtils {
2121
22+ public static final String DEFAULT_CLIENT_EMAIL =
"[email protected] " ;
23+
2224 private TestUtils () {}
2325
2426 /**
2527 * Creates a random Service Account file for testing purpose
2628 */
2729 public static byte [] createServiceAccount (final Random random ) {
28- return createServiceAccount (random , UUID .randomUUID ().toString ());
30+ return createServiceAccount (random , UUID .randomUUID ().toString (), DEFAULT_CLIENT_EMAIL );
2931 }
3032
3133 /**
3234 * Creates a random Service Account file for testing purpose with a specific private key ID.
3335 */
3436 public static byte [] createServiceAccount (final Random random , String privateKeyId ) {
37+ return createServiceAccount (random , privateKeyId , DEFAULT_CLIENT_EMAIL );
38+ }
39+
40+ /**
41+ * Creates a random Service Account file for testing purpose with a specific private key ID and client email.
42+ */
43+ public static byte [] createServiceAccount (final Random random , String privateKeyId , String clientEmail ) {
3544 try {
3645 final KeyPairGenerator keyPairGenerator = KeyPairGenerator .getInstance ("RSA" );
3746 keyPairGenerator .initialize (2048 );
@@ -45,7 +54,7 @@ public static byte[] createServiceAccount(final Random random, String privateKey
4554 builder .field ("project_id" , "test" );
4655 builder .field ("private_key_id" , privateKeyId );
4756 builder .field ("private_key" , "-----BEGIN PRIVATE KEY-----\n " + privateKey + "\n -----END PRIVATE KEY-----\n " );
48- builder .
field (
"client_email" ,
"[email protected] " );
57+ builder .field ("client_email" , clientEmail );
4958 builder .field ("client_id" , String .valueOf (Math .abs (random .nextLong ())));
5059 }
5160 builder .endObject ();
0 commit comments