Skip to content

Commit e7dd30f

Browse files
authored
Revert "[TT-5588] [OAS] gateway apiKey import generates unnecessary object" (#7299)
### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-5588" title="TT-5588" target="_blank">TT-5588</a></summary> <br /> <table> <tr> <th>Summary</th> <td>[OAS] gateway apiKey import generates unnecessary object</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td><a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20codilime_refined%20ORDER%20BY%20created%20DESC" title="codilime_refined">codilime_refined</a></td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- Reverts #7270 ___ ### **PR Type** Bug fix, Tests ___ ### **Description** Re-enable JSON inlining for `AuthSources` Remove test asserting non-serialization Keep token auth fill/roundtrip behavior intact Align JSON tags with intended API shape ___ ### Diagram Walkthrough ```mermaid flowchart LR Token["Token struct"] AuthSources["AuthSources fields"] JSONTag["json:\",inline\""] TestRemoval["Remove non-serialization test"] Token -- contains --> AuthSources AuthSources -- applied via --> JSONTag JSONTag -- implies --> InlinedInJSON["Inlined in JSON output"] TestRemoval -- aligns with --> InlinedInJSON ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>security.go</strong><dd><code>Re-enable JSON inlining for AuthSources in Token</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> apidef/oas/security.go <ul><li>Change <code>Token.AuthSources</code> JSON tag to <code>",inline"</code><br> <li> Revert exclusion from JSON serialization</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7299/files#diff-15e7d47137452ca4f3f6139aa8c007cdb426152c41846f712f8bf5dfb607afcc">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>security_test.go</strong><dd><code>Delete test asserting AuthSources not serialized</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> apidef/oas/security_test.go <ul><li>Remove round-trip JSON test for <code>AuthSources</code> omission<br> <li> Keep existing Token tests intact</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7299/files#diff-5184167309db0462243e424baca87b5bb668962d8cc1076629fdcf11f00487e5">+0/-15</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
1 parent 35d2b2d commit e7dd30f

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

apidef/oas/security.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Token struct {
3030
Enabled bool `bson:"enabled" json:"enabled"` // required
3131

3232
// AuthSources contains the configuration for authentication sources.
33-
AuthSources `bson:",inline" json:"-"`
33+
AuthSources `bson:",inline" json:",inline"`
3434

3535
// EnableClientCertificate allows to create dynamic keys based on certificates.
3636
//

apidef/oas/security_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package oas
22

33
import (
4-
"encoding/json"
54
"sort"
65
"testing"
76

@@ -277,20 +276,6 @@ func TestOAS_Token(t *testing.T) {
277276
convertedOAS.fillToken(api)
278277

279278
assert.Equal(t, oas, convertedOAS)
280-
281-
// Make sure AuthSources are not serialized into json.
282-
token.Query = &AuthSource{Enabled: true}
283-
token.Header = &AuthSource{Enabled: true}
284-
token.Cookie = &AuthSource{Enabled: true}
285-
bytes, err := json.Marshal(token)
286-
assert.NoError(t, err)
287-
288-
var unmarshalledToken Token
289-
err = json.Unmarshal(bytes, &unmarshalledToken)
290-
assert.NoError(t, err)
291-
assert.Nil(t, unmarshalledToken.Query)
292-
assert.Nil(t, unmarshalledToken.Header)
293-
assert.Nil(t, unmarshalledToken.Cookie)
294279
}
295280

296281
func TestOAS_Token_MultipleSecuritySchemes(t *testing.T) {

0 commit comments

Comments
 (0)