File tree Expand file tree Collapse file tree
javatests/com/google/auth/oauth2
java/com/google/auth/oauth2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -553,13 +553,17 @@ public Builder setCaCertPath(String caCertPath) {
553553
554554 @ CanIgnoreReturnValue
555555 public Builder setGdchAudience (String apiAudience ) {
556- this .apiAudience = apiAudience ;
556+ this .apiAudience =
557+ Preconditions .checkNotNull (
558+ apiAudience , "Audience cannot be null or empty for GDCH service account credentials." );
557559 return this ;
558560 }
559561
560562 @ CanIgnoreReturnValue
561563 @ ObsoleteApi ("Use setGdchAudience(String) instead" )
562564 public Builder setGdchAudience (URI apiAudience ) {
565+ Preconditions .checkNotNull (
566+ apiAudience , "Audience cannot be null or empty for GDCH service account credentials." );
563567 this .apiAudience = apiAudience .toString ();
564568 return this ;
565569 }
Original file line number Diff line number Diff line change @@ -1232,6 +1232,24 @@ void signUsingEsSha256_validStructure() throws Exception {
12321232 assertEquals (64 , signatureBytes .length );
12331233 }
12341234
1235+ @ Test
1236+ void builder_setGdchAudience_nullString () {
1237+ GdchCredentials .Builder builder = GdchCredentials .newBuilder ();
1238+ NullPointerException ex =
1239+ assertThrows (NullPointerException .class , () -> builder .setGdchAudience ((String ) null ));
1240+ assertEquals (
1241+ "Audience cannot be null or empty for GDCH service account credentials." , ex .getMessage ());
1242+ }
1243+
1244+ @ Test
1245+ void builder_setGdchAudience_nullUri () {
1246+ GdchCredentials .Builder builder = GdchCredentials .newBuilder ();
1247+ NullPointerException ex =
1248+ assertThrows (NullPointerException .class , () -> builder .setGdchAudience ((URI ) null ));
1249+ assertEquals (
1250+ "Audience cannot be null or empty for GDCH service account credentials." , ex .getMessage ());
1251+ }
1252+
12351253 static GenericJson writeGdchServiceAccountJson (
12361254 String formatVersion ,
12371255 String project ,
You can’t perform that action at this time.
0 commit comments