@@ -86,11 +86,12 @@ func testAccCheckIdentityOidcKeyDestroy(s *terraform.State) error {
8686 if rs .Type != "vault_identity_oidc_key" {
8787 continue
8888 }
89- secret , err := client .Logical ().Read (identityEntityIDPath (rs .Primary .ID ))
89+ resp , err := identityOidcKeyApiRead (rs .Primary .Attributes ["name" ], client )
90+
9091 if err != nil {
9192 return fmt .Errorf ("error checking for identity oidc key %q: %s" , rs .Primary .ID , err )
9293 }
93- if secret != nil {
94+ if resp != nil {
9495 return fmt .Errorf ("identity oidc key %q still exists" , rs .Primary .ID )
9596 }
9697 }
@@ -110,12 +111,11 @@ func testAccIdentityOidcKeyCheckAttrs() resource.TestCheckFunc {
110111 }
111112
112113 id := instanceState .ID
113-
114114 path := identityOidcKeyPath (id )
115115 client := testProvider .Meta ().(* api.Client )
116- resp , err := client . Logical (). Read ( path )
116+ resp , err := identityOidcKeyApiRead ( id , client )
117117 if err != nil {
118- return fmt .Errorf ("%q doesn't exist" , path )
118+ return fmt .Errorf ("%q doesn't exist" , id )
119119 }
120120
121121 attrs := map [string ]string {
@@ -125,36 +125,36 @@ func testAccIdentityOidcKeyCheckAttrs() resource.TestCheckFunc {
125125 "allowed_client_ids" : "allowed_client_ids" ,
126126 }
127127 for stateAttr , apiAttr := range attrs {
128- if resp . Data [apiAttr ] == nil && instanceState .Attributes [stateAttr ] == "" {
128+ if resp [apiAttr ] == nil && instanceState .Attributes [stateAttr ] == "" {
129129 continue
130130 }
131131 var match bool
132- switch resp . Data [apiAttr ].(type ) {
132+ switch resp [apiAttr ].(type ) {
133133 case json.Number :
134- apiData , err := resp . Data [apiAttr ].(json.Number ).Int64 ()
134+ apiData , err := resp [apiAttr ].(json.Number ).Int64 ()
135135 if err != nil {
136- return fmt .Errorf ("expected API field %s to be an int, was %q" , apiAttr , resp . Data [apiAttr ])
136+ return fmt .Errorf ("expected API field %s to be an int, was %q" , apiAttr , resp [apiAttr ])
137137 }
138138 stateData , err := strconv .ParseInt (instanceState .Attributes [stateAttr ], 10 , 64 )
139139 if err != nil {
140140 return fmt .Errorf ("expected state field %s to be an int, was %q" , stateAttr , instanceState .Attributes [stateAttr ])
141141 }
142142 match = apiData == stateData
143143 case bool :
144- if _ , ok := resp . Data [apiAttr ]; ! ok && instanceState .Attributes [stateAttr ] == "" {
144+ if _ , ok := resp [apiAttr ]; ! ok && instanceState .Attributes [stateAttr ] == "" {
145145 match = true
146146 } else {
147147 stateData , err := strconv .ParseBool (instanceState .Attributes [stateAttr ])
148148 if err != nil {
149149 return fmt .Errorf ("expected state field %s to be a bool, was %q" , stateAttr , instanceState .Attributes [stateAttr ])
150150 }
151- match = resp . Data [apiAttr ] == stateData
151+ match = resp [apiAttr ] == stateData
152152 }
153153 case []interface {}:
154- apiData := resp . Data [apiAttr ].([]interface {})
154+ apiData := resp [apiAttr ].([]interface {})
155155 length := instanceState .Attributes [stateAttr + ".#" ]
156156 if length == "" {
157- if len (resp . Data [apiAttr ].([]interface {})) != 0 {
157+ if len (resp [apiAttr ].([]interface {})) != 0 {
158158 return fmt .Errorf ("expected state field %s to have %d entries, had 0" , stateAttr , len (apiData ))
159159 }
160160 match = true
@@ -184,10 +184,10 @@ func testAccIdentityOidcKeyCheckAttrs() resource.TestCheckFunc {
184184 match = true
185185 }
186186 default :
187- match = resp . Data [apiAttr ] == instanceState .Attributes [stateAttr ]
187+ match = resp [apiAttr ] == instanceState .Attributes [stateAttr ]
188188 }
189189 if ! match {
190- return fmt .Errorf ("expected %s (%s in state) of %q to be %q, got %q" , apiAttr , stateAttr , path , instanceState .Attributes [stateAttr ], resp . Data [apiAttr ])
190+ return fmt .Errorf ("expected %s (%s in state) of %q to be %q, got %q" , apiAttr , stateAttr , path , instanceState .Attributes [stateAttr ], resp [apiAttr ])
191191 }
192192 }
193193 return nil
0 commit comments