@@ -153,7 +153,7 @@ func TestManageIDPResourceExistingFound(t *testing.T) {
153153 for name , tc := range tests {
154154 tc := tc
155155 t .Run (name , func (t * testing.T ) {
156- existingRI := idpInstanceRI (tc .existingName )
156+ existingRI := idpMetadataInstanceRI (tc .existingName )
157157 createCalled := false
158158 subResourceCalled := false
159159
@@ -677,7 +677,7 @@ func TestManageIDPResourceWithMetadataExistingFound(t *testing.T) {
677677 createCount := 0
678678 apicClient := & mock.Client {
679679 GetAPIV1ResourceInstancesMock : func (_ map [string ]string , _ string ) ([]* apiv1.ResourceInstance , error ) {
680- return []* apiv1.ResourceInstance {idpInstanceRI (tc .existingName )}, nil
680+ return []* apiv1.ResourceInstance {idpMetadataInstanceRI (tc .existingName )}, nil
681681 },
682682 CreateOrUpdateResourceMock : func (ri apiv1.Interface ) (* apiv1.ResourceInstance , error ) {
683683 createCount ++
@@ -851,8 +851,8 @@ func TestManageIDPResource(t *testing.T) {
851851 wantCachedAfter bool
852852 }{
853853 "nil metadata returns empty without any API call" : {
854- metadata : nil ,
855- assertResult : func (t * testing.T , result string ) { assert .Empty (t , result ) },
854+ metadata : nil ,
855+ assertResult : func (t * testing.T , result string ) { assert .Empty (t , result ) },
856856 wantQueryCount : 0 ,
857857 },
858858 "local cache hit skips Engage query and returns cached name" : {
@@ -862,49 +862,27 @@ func TestManageIDPResource(t *testing.T) {
862862 wantQueryCount : 0 ,
863863 wantCachedAfter : true ,
864864 },
865- "Engage query finds IdentityProviderMetadata with non-empty scope name" : {
866- metadata : testMeta ,
867- tokenEndpointInstances : []* apiv1.ResourceInstance {idpMetadataInstanceRI ("found-idp" )},
868- assertResult : func (t * testing.T , result string ) { assert .Equal (t , "found-idp" , result ) },
869- wantQueryCount : 1 ,
870- wantCachedAfter : true ,
871- },
872- "Engage query finds result with empty scope name falls through to create" : {
873- metadata : testMeta ,
874- tokenEndpointInstances : []* apiv1.ResourceInstance {idpMetadataInstanceRI ("" )},
875- metadataURLInstances : []* apiv1.ResourceInstance {},
876- assertResult : func (t * testing.T , result string ) { assert .NotEmpty (t , result ) },
877- wantQueryCount : 2 ,
878- wantCreateCalled : true ,
879- wantCachedAfter : true ,
880- },
881- "Engage query error falls through to create" : {
882- metadata : testMeta ,
883- tokenEndpointErr : errors .New ("query error" ),
884- metadataURLInstances : []* apiv1.ResourceInstance {},
885- assertResult : func (t * testing.T , result string ) { assert .NotEmpty (t , result ) },
886- wantQueryCount : 2 ,
887- wantCreateCalled : true ,
888- wantCachedAfter : true ,
865+ "creates resource when not in cache" : {
866+ metadata : testMeta ,
867+ assertResult : func (t * testing.T , result string ) { assert .NotEmpty (t , result ) },
868+ wantQueryCount : 1 ,
869+ wantCreateCalled : true ,
870+ wantCachedAfter : true ,
889871 },
890- "not in cache or Engage creates resource and caches by token endpoint" : {
891- metadata : testMeta ,
892- tokenEndpointInstances : []* apiv1.ResourceInstance {},
893- metadataURLInstances : []* apiv1.ResourceInstance {},
894- assertResult : func (t * testing.T , result string ) { assert .NotEmpty (t , result ) },
895- wantQueryCount : 2 ,
896- wantCreateCalled : true ,
897- wantCachedAfter : true ,
872+ "creates and caches resource when not in cache" : {
873+ metadata : testMeta ,
874+ assertResult : func (t * testing.T , result string ) { assert .NotEmpty (t , result ) },
875+ wantQueryCount : 1 ,
876+ wantCreateCalled : true ,
877+ wantCachedAfter : true ,
898878 },
899879 "create failure returns empty name and nothing cached" : {
900- metadata : testMeta ,
901- tokenEndpointInstances : []* apiv1.ResourceInstance {},
902- metadataURLInstances : []* apiv1.ResourceInstance {},
903- createErr : errors .New ("create failed" ),
904- assertResult : func (t * testing.T , result string ) { assert .Empty (t , result ) },
905- wantQueryCount : 2 ,
906- wantCreateCalled : true ,
907- wantCachedAfter : false ,
880+ metadata : testMeta ,
881+ createErr : errors .New ("create failed" ),
882+ assertResult : func (t * testing.T , result string ) { assert .Empty (t , result ) },
883+ wantQueryCount : 1 ,
884+ wantCreateCalled : true ,
885+ wantCachedAfter : false ,
908886 },
909887 }
910888
@@ -949,7 +927,7 @@ func TestManageIDPResource(t *testing.T) {
949927 setIDPMetadataResourceName (testMeta .TokenEndpoint , tc .preloadCacheName )
950928 }
951929
952- result := ManageIDPResource (logger , tc .metadata )
930+ result := ManageIDPResource (logger , testIDPName , tc .metadata )
953931
954932 tc .assertResult (t , result )
955933 assert .Equal (t , tc .wantQueryCount , queryCount )
0 commit comments