Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token update by hash generates new hash entry in redis #3109

Closed
ilijabojanovic opened this issue May 28, 2020 · 1 comment
Closed

Token update by hash generates new hash entry in redis #3109

ilijabojanovic opened this issue May 28, 2020 · 1 comment

Comments

@ilijabojanovic
Copy link
Member

Branch/Environment/Version

  • Branch/Version: Master/Stable
  • Environment: All

Describe the bug
When user updates token by hash, gateway will create new hash entry in redis database.

Reproduction steps

  1. Create new token
  2. Search that token by hash
  3. On keys edit page just update token

Actual behavior
Before token update in redis we will have hash like this api-3f2736714c0076a2, when we update token in redis we will have two entries:

{
    "data": {
        "keys": [
            "3f2736714c0076a2",
"eyJvcmciOiI1ZWNlZGFlMjQ1YjY0MjBhMGE1ZDQxNTgiLCJpZCI6IjhmNDcxNWMwY2Q5YzMwN2MiLCJoIjoibXVybXVyNjQifQ==",
        ]
    },

Expected behavior
Update token by hash should not create new token entry in redis.

Screenshots/Video
If applicable, add screenshots or video to help explain your problem.

Logs (debug mode or log file):
Log from console or from log file.

Configuration (tyk config file):
Attach tyk configuration file

Additional context
Add any other context about the problem here.

@lghiur lghiur assigned sredxny and unassigned sredxny May 28, 2020
buger pushed a commit that referenced this issue Jul 25, 2020
<!-- Provide a general summary of your changes in the Title above -->

## Description
On update keys, we should not call twice `doAddOrUpdate` as this create duplicates for the same key in redis, instead, we should check if we are dealing with a custom key or not, and therefore perform the proper action.

## Related Issue
#3109

## Motivation and Context
Give solution to #3109

## How This Has Been Tested
- Run GW and Dashboard with `"hash_keys": true`
- Create a custom key via gw api
- Update custom key...and check that the value was updated and an additional registry was not created in redis
- Create key via dashboard
- Update key via dashboard, check that the value was updated but an additional registry in redis was not created for the same key
- Do the same but now with `"hash_keys": false`

## Screenshots (if appropriate)

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [x] 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 you're unsure about any of these, don't hesitate to ask; we're here to help! -->
- [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). If pulling from your own
      fork, don't request your `master`!
- [x] Make sure you are making a pull request against the **`master` branch** (left side). Also, you should start
      *your branch* off *our latest `master`*.
- [ ] My change requires a change to the documentation.
  - [ ] If you've changed APIs, describe what needs to be updated in the documentation.
  - [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run `go mod tidy && go mod vendor`
- [ ] When updating library version must provide reason/explanation for this update.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] Check your code additions will not fail linting checks:
  - [x] `go fmt -s`
  - [x] `go vet`
tykbot bot pushed a commit that referenced this issue Jul 25, 2020
<!-- Provide a general summary of your changes in the Title above -->

## Description
On update keys, we should not call twice `doAddOrUpdate` as this create duplicates for the same key in redis, instead, we should check if we are dealing with a custom key or not, and therefore perform the proper action.

## Related Issue
#3109

## Motivation and Context
Give solution to #3109

## How This Has Been Tested
- Run GW and Dashboard with `"hash_keys": true`
- Create a custom key via gw api
- Update custom key...and check that the value was updated and an additional registry was not created in redis
- Create key via dashboard
- Update key via dashboard, check that the value was updated but an additional registry in redis was not created for the same key
- Do the same but now with `"hash_keys": false`

## Screenshots (if appropriate)

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [x] 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 you're unsure about any of these, don't hesitate to ask; we're here to help! -->
- [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). If pulling from your own
      fork, don't request your `master`!
- [x] Make sure you are making a pull request against the **`master` branch** (left side). Also, you should start
      *your branch* off *our latest `master`*.
- [ ] My change requires a change to the documentation.
  - [ ] If you've changed APIs, describe what needs to be updated in the documentation.
  - [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run `go mod tidy && go mod vendor`
- [ ] When updating library version must provide reason/explanation for this update.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] Check your code additions will not fail linting checks:
  - [x] `go fmt -s`
  - [x] `go vet`

(cherry picked from commit 110cdf7)
tykbot bot pushed a commit that referenced this issue Jul 25, 2020
<!-- Provide a general summary of your changes in the Title above -->

## Description
On update keys, we should not call twice `doAddOrUpdate` as this create duplicates for the same key in redis, instead, we should check if we are dealing with a custom key or not, and therefore perform the proper action.

## Related Issue
#3109

## Motivation and Context
Give solution to #3109

## How This Has Been Tested
- Run GW and Dashboard with `"hash_keys": true`
- Create a custom key via gw api
- Update custom key...and check that the value was updated and an additional registry was not created in redis
- Create key via dashboard
- Update key via dashboard, check that the value was updated but an additional registry in redis was not created for the same key
- Do the same but now with `"hash_keys": false`

## Screenshots (if appropriate)

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [x] 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 you're unsure about any of these, don't hesitate to ask; we're here to help! -->
- [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). If pulling from your own
      fork, don't request your `master`!
- [x] Make sure you are making a pull request against the **`master` branch** (left side). Also, you should start
      *your branch* off *our latest `master`*.
- [ ] My change requires a change to the documentation.
  - [ ] If you've changed APIs, describe what needs to be updated in the documentation.
  - [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run `go mod tidy && go mod vendor`
- [ ] When updating library version must provide reason/explanation for this update.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] Check your code additions will not fail linting checks:
  - [x] `go fmt -s`
  - [x] `go vet`

(cherry picked from commit 110cdf7)
tykbot bot pushed a commit that referenced this issue Jul 25, 2020
<!-- Provide a general summary of your changes in the Title above -->

## Description
On update keys, we should not call twice `doAddOrUpdate` as this create duplicates for the same key in redis, instead, we should check if we are dealing with a custom key or not, and therefore perform the proper action.

## Related Issue
#3109

## Motivation and Context
Give solution to #3109

## How This Has Been Tested
- Run GW and Dashboard with `"hash_keys": true`
- Create a custom key via gw api
- Update custom key...and check that the value was updated and an additional registry was not created in redis
- Create key via dashboard
- Update key via dashboard, check that the value was updated but an additional registry in redis was not created for the same key
- Do the same but now with `"hash_keys": false`

## Screenshots (if appropriate)

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [x] 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 you're unsure about any of these, don't hesitate to ask; we're here to help! -->
- [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). If pulling from your own
      fork, don't request your `master`!
- [x] Make sure you are making a pull request against the **`master` branch** (left side). Also, you should start
      *your branch* off *our latest `master`*.
- [ ] My change requires a change to the documentation.
  - [ ] If you've changed APIs, describe what needs to be updated in the documentation.
  - [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run `go mod tidy && go mod vendor`
- [ ] When updating library version must provide reason/explanation for this update.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] Check your code additions will not fail linting checks:
  - [x] `go fmt -s`
  - [x] `go vet`

(cherry picked from commit 110cdf7)
@ilijabojanovic
Copy link
Member Author

Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants