@@ -508,6 +508,84 @@ func TestDeleteOIDCProviderConfigError(t *testing.T) {
508508 }
509509}
510510
511+ func TestOIDCProviderConfigs (t * testing.T ) {
512+ template := `{
513+ "oauthIdpConfigs": [
514+ %s,
515+ %s,
516+ %s
517+ ],
518+ "nextPageToken": ""
519+ }`
520+ response := fmt .Sprintf (template , oidcConfigResponse , oidcConfigResponse , oidcConfigResponse )
521+ s := echoServer ([]byte (response ), t )
522+ defer s .Close ()
523+
524+ want := []* OIDCProviderConfig {
525+ oidcProviderConfig ,
526+ oidcProviderConfig ,
527+ oidcProviderConfig ,
528+ }
529+ wantPath := "/projects/mock-project-id/oauthIdpConfigs"
530+
531+ testIterator := func (iter * OIDCProviderConfigIterator , token string , req string ) {
532+ count := 0
533+ for i := 0 ; i < len (want ); i ++ {
534+ config , err := iter .Next ()
535+ if err == iterator .Done {
536+ break
537+ }
538+ if err != nil {
539+ t .Fatal (err )
540+ }
541+ if ! reflect .DeepEqual (config , want [i ]) {
542+ t .Errorf ("OIDCProviderConfigs(%q) = %#v; want = %#v" , token , config , want [i ])
543+ }
544+ count ++
545+ }
546+ if count != len (want ) {
547+ t .Errorf ("OIDCProviderConfigs(%q) = %d; want = %d" , token , count , len (want ))
548+ }
549+ if _ , err := iter .Next (); err != iterator .Done {
550+ t .Errorf ("OIDCProviderConfigs(%q) = %v; want = %v" , token , err , iterator .Done )
551+ }
552+
553+ url := s .Req [len (s .Req )- 1 ].URL
554+ if url .Path != wantPath {
555+ t .Errorf ("OIDCProviderConfigs(%q) = %q; want = %q" , token , url .Path , wantPath )
556+ }
557+
558+ // Check the query string of the last HTTP request made.
559+ gotReq := url .Query ().Encode ()
560+ if gotReq != req {
561+ t .Errorf ("OIDCProviderConfigs(%q) = %q; want = %v" , token , gotReq , req )
562+ }
563+ }
564+
565+ client := s .Client .pcc
566+ testIterator (
567+ client .OIDCProviderConfigs (context .Background (), "" ),
568+ "" ,
569+ "pageSize=100" )
570+ testIterator (
571+ client .OIDCProviderConfigs (context .Background (), "pageToken" ),
572+ "pageToken" ,
573+ "pageSize=100&pageToken=pageToken" )
574+ }
575+
576+ func TestOIDCProviderConfigsError (t * testing.T ) {
577+ s := echoServer ([]byte ("{}" ), t )
578+ defer s .Close ()
579+ s .Status = http .StatusInternalServerError
580+
581+ client := s .Client .pcc
582+ it := client .OIDCProviderConfigs (context .Background (), "" )
583+ config , err := it .Next ()
584+ if config != nil || err == nil || ! IsUnknown (err ) {
585+ t .Errorf ("OIDCProviderConfigs() = (%v, %v); want = (nil, %q)" , config , err , "unknown-error" )
586+ }
587+ }
588+
511589func TestSAMLProviderConfig (t * testing.T ) {
512590 s := echoServer ([]byte (samlConfigResponse ), t )
513591 defer s .Close ()
@@ -1074,6 +1152,7 @@ func TestSAMLProviderConfigs(t *testing.T) {
10741152 samlProviderConfig ,
10751153 samlProviderConfig ,
10761154 }
1155+ wantPath := "/projects/mock-project-id/inboundSamlConfigs"
10771156
10781157 testIterator := func (iter * SAMLProviderConfigIterator , token string , req string ) {
10791158 count := 0
@@ -1094,13 +1173,18 @@ func TestSAMLProviderConfigs(t *testing.T) {
10941173 t .Errorf ("SAMLProviderConfigs(%q) = %d; want = %d" , token , count , len (want ))
10951174 }
10961175 if _ , err := iter .Next (); err != iterator .Done {
1097- t .Errorf ("SAMLProviderConfigs(%q) = %v, want = %v" , token , err , iterator .Done )
1176+ t .Errorf ("SAMLProviderConfigs(%q) = %v; want = %v" , token , err , iterator .Done )
1177+ }
1178+
1179+ url := s .Req [len (s .Req )- 1 ].URL
1180+ if url .Path != wantPath {
1181+ t .Errorf ("SAMLProviderConfigs(%q) = %q; want = %q" , token , url .Path , wantPath )
10981182 }
10991183
11001184 // Check the query string of the last HTTP request made.
1101- gotReq := s . Req [ len ( s . Req ) - 1 ]. URL .Query ().Encode ()
1185+ gotReq := url .Query ().Encode ()
11021186 if gotReq != req {
1103- t .Errorf ("SAMLProviderConfigs(%q) = %q, want = %v" , token , gotReq , req )
1187+ t .Errorf ("SAMLProviderConfigs(%q) = %q; want = %v" , token , gotReq , req )
11041188 }
11051189 }
11061190
0 commit comments