Skip to content

Commit

Permalink
TT-13185, fixed lines lost in merge conflicts (#6681)
Browse files Browse the repository at this point in the history
### **User description**
<details open>
<summary><a href="https://tyktech.atlassian.net/browse/TT-13185"
title="TT-13185" target="_blank">TT-13185</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>Implement OAuth 2.0 Password Flow for API Gateway Authentication
with Upstream Server</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Story"
src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium"
/>
        Story
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>Ready for Testing</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%20QA_Fail%20ORDER%20BY%20created%20DESC"
title="QA_Fail">QA_Fail</a></td>
    </tr>
  </table>
</details>
<!--
  do not remove this marker as it will break jira-lint's functionality.
  added_by_jira_lint
-->

---

<!-- Provide a general summary of your changes in the Title above -->

## Description

<!-- Describe your changes in detail -->

## Related Issue

<!-- This project only accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- OSS: Please link to the issue here. Tyk: please create/link the
JIRA ticket. -->

## Motivation and Context

<!-- Why is this change required? What problem does it solve? -->

## How This Has Been Tested

<!-- Please describe in detail how you tested your changes -->
<!-- Include details of your testing environment, and the tests -->
<!-- you ran to see how your change affects other areas of the code,
etc. -->
<!-- This information is helpful for reviewers and QA. -->

## Screenshots (if appropriate)

## Types of changes

<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test
coverage to functionality)

## Checklist

<!-- Go over all the following points, and put an `x` in all the boxes
that apply -->
<!-- If there are no documentation updates required, mark the item as
checked. -->
<!-- Raise up any additional concerns not covered by the checklist. -->

- [ ] I ensured that the documentation is up to date
- [ ] I explained why this PR updates go.mod in detail with reasoning
why it's required
- [ ] I would like a code coverage CI quality gate exception and have
explained why


___

### **PR Type**
enhancement, bug fix


___

### **Description**
- Enhanced the `Fill` and `ExtractTo` methods for `ClientCredentials`
and `PasswordAuthentication` to handle `ExtraMetadata`, `ClientID`, and
`ClientSecret` fields.
- Updated test assertions in `oas_test.go` by removing lines related to
`ExtraMetadata`.
- Fixed lines lost in merge conflicts related to OAuth 2.0 Password Flow
implementation.



___



PRDescriptionHeader.CHANGES_WALKTHROUGH
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>oas_test.go</strong><dd><code>Update test assertions by
removing `ExtraMetadata` lines</code>&nbsp; </dd></summary>
<hr>

apidef/oas/oas_test.go

- Removed lines related to `ExtraMetadata` in test assertions.



</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6681/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>upstream.go</strong><dd><code>Enhance OAuth handling
with `ExtraMetadata` and credentials</code></dd></summary>
<hr>

apidef/oas/upstream.go

<li>Added <code>ExtraMetadata</code> field handling in <code>Fill</code>
and <code>ExtractTo</code> methods for
<br><code>ClientCredentials</code>.<br> <li> Added <code>ClientID</code>
and <code>ClientSecret</code> field handling in <code>Fill</code> and
<code>ExtractTo</code> <br>methods for
<code>PasswordAuthentication</code>.<br>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6681/files#diff-7b0941c7f37fe5a2a23047e0822a65519ca11c371660f36555b59a60f000e3f4">+8/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information
  • Loading branch information
andrei-tyk authored Oct 29, 2024
1 parent bb09d39 commit dafbab6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions apidef/oas/oas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,8 @@ func TestOAS_ExtractTo_ResetAPIDefinition(t *testing.T) {
"APIDefinition.AnalyticsPlugin.PluginPath",
"APIDefinition.AnalyticsPlugin.FuncName",
"APIDefinition.UpstreamAuth.OAuth.ClientCredentials.Enabled",
"APIDefinition.UpstreamAuth.OAuth.ClientCredentials.ExtraMetadata[0]",
"APIDefinition.UpstreamAuth.OAuth.PasswordAuthentication.Header.Enabled",
"APIDefinition.UpstreamAuth.OAuth.PasswordAuthentication.Header.Name",
"APIDefinition.UpstreamAuth.OAuth.PasswordAuthentication.ExtraMetadata[0]",
}

assert.Equal(t, expectedFields, noOASSupportFields)
Expand Down
8 changes: 8 additions & 0 deletions apidef/oas/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ func (c *ClientCredentials) Fill(api apidef.ClientCredentials) {
c.ClientSecret = api.ClientSecret
c.TokenURL = api.TokenURL
c.Scopes = api.Scopes
c.ExtraMetadata = api.ExtraMetadata

if c.Header == nil {
c.Header = &AuthSource{}
Expand All @@ -717,10 +718,13 @@ func (c *ClientCredentials) Fill(api apidef.ClientCredentials) {
}

func (p *PasswordAuthentication) Fill(api apidef.PasswordAuthentication) {
p.ClientID = api.ClientID
p.ClientSecret = api.ClientSecret
p.Username = api.Username
p.Password = api.Password
p.TokenURL = api.TokenURL
p.Scopes = api.Scopes
p.ExtraMetadata = api.ExtraMetadata
if p.Header == nil {
p.Header = &AuthSource{}
}
Expand Down Expand Up @@ -756,6 +760,7 @@ func (c *ClientCredentials) ExtractTo(api *apidef.ClientCredentials) {
api.ClientSecret = c.ClientSecret
api.TokenURL = c.TokenURL
api.Scopes = c.Scopes
api.ExtraMetadata = c.ExtraMetadata

if c.Header == nil {
c.Header = &AuthSource{}
Expand All @@ -767,10 +772,13 @@ func (c *ClientCredentials) ExtractTo(api *apidef.ClientCredentials) {
}

func (p *PasswordAuthentication) ExtractTo(api *apidef.PasswordAuthentication) {
api.ClientID = p.ClientID
api.ClientSecret = p.ClientSecret
api.Username = p.Username
api.Password = p.Password
api.TokenURL = p.TokenURL
api.Scopes = p.Scopes
api.ExtraMetadata = p.ExtraMetadata
}

func (u *UpstreamOAuth) ExtractTo(api *apidef.UpstreamOAuth) {
Expand Down

0 comments on commit dafbab6

Please sign in to comment.