3333import static com .google .common .truth .Truth .assertThat ;
3434import static org .junit .jupiter .api .Assertions .assertEquals ;
3535import static org .junit .jupiter .api .Assertions .assertFalse ;
36+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
3637import static org .junit .jupiter .api .Assertions .assertNotNull ;
3738import static org .junit .jupiter .api .Assertions .assertNotSame ;
3839import static org .junit .jupiter .api .Assertions .assertThrows ;
6364import com .google .common .collect .ImmutableMap ;
6465import com .google .common .truth .Truth ;
6566import java .io .IOException ;
66- import java .net .URI ;
6767import java .util .Collections ;
6868import java .util .List ;
6969import java .util .Map ;
@@ -1025,7 +1025,8 @@ void testCreateClientContext_withGdchCredentialAndValidAudience() throws IOExcep
10251025 }
10261026
10271027 @ Test
1028- void testCreateClientContext_withGdchCredentialAndInvalidAudience_throws () throws IOException {
1028+ void testCreateClientContext_withGdchCredentialAndInvalidAudience_doesNotThrow ()
1029+ throws IOException {
10291030 TransportChannelProvider transportChannelProvider = getFakeTransportChannelProvider ();
10301031 Credentials creds = getMockGdchCredentials ();
10311032 CredentialsProvider provider = FixedCredentialsProvider .create (creds );
@@ -1041,17 +1042,14 @@ void testCreateClientContext_withGdchCredentialAndInvalidAudience_throws() throw
10411042 clientSettingsBuilder .setCredentialsProvider (provider );
10421043 clientSettingsBuilder .setTransportChannelProvider (transportChannelProvider );
10431044 final ClientSettings withGdchCredentialsAndMalformedApiAudience = clientSettingsBuilder .build ();
1044- // should throw
1045- String exMessage =
1046- assertThrows (
1047- IllegalArgumentException .class ,
1048- () -> ClientContext .create (withGdchCredentialsAndMalformedApiAudience ))
1049- .getMessage ();
1050- assertThat (exMessage ).contains ("The GDC-H API audience string is not a valid URI" );
1045+
1046+ // There is an invalid URI for the GDCH audience, but we do not validate the URI
1047+ // There are some use cases where there the GDCH audience is not a URI.
1048+ ClientContext clientContext = ClientContext .create (withGdchCredentialsAndMalformedApiAudience );
1049+ assertInstanceOf (GdchCredentials .class , clientContext .getCredentials ());
10511050
10521051 Credentials fromProvider = provider .getCredentials ();
1053- verify ((GdchCredentials ) fromProvider , times (0 ))
1054- .createWithGdchAudience (URI .create ("test-endpoint" ));
1052+ verify ((GdchCredentials ) fromProvider , times (0 )).createWithGdchAudience ("test-endpoint" );
10551053 }
10561054
10571055 @ Test
0 commit comments