diff options
author | E99p1ant <i@github.red> | 2022-06-05 13:34:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-05 13:34:21 +0800 |
commit | a328e7ccc4f94e19cddfe5894636228663f5c7fa (patch) | |
tree | 34d827770f004a40eb8dc1feb44109e63452d5a0 /internal/db/backup_test.go | |
parent | 155cae1de8916fc3fde78f350763034b7422caee (diff) |
access_token: encrypt access token with SHA256 (#7008)
* access_token: encrypt access token with SHA256
* revert list access token
* fix lint
* generate schemadoc
* add database migrations
* fix tests
* fix tests
* add test case for access token golden
* fix test in postgres
* `Sha256` -> `SHA256`
* Use GORM for migration
* task generate-schemadoc
* Use unique
* change migration name
* allow read
* task generate-schemadoc
* add changelog
* fix lint error
* update changelog
* remove Debug
* add comments
Co-authored-by: Joe Chen <jc@unknwon.io>
Diffstat (limited to 'internal/db/backup_test.go')
-rw-r--r-- | internal/db/backup_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/db/backup_test.go b/internal/db/backup_test.go index 4bbef8f6..e30ac7a2 100644 --- a/internal/db/backup_test.go +++ b/internal/db/backup_test.go @@ -63,6 +63,7 @@ func setupDBToDump(t *testing.T, db *gorm.DB) { UserID: 1, Name: "test1", Sha1: cryptoutil.SHA1("2910d03d-c0b5-4f71-bad5-c4086e4efae3"), + SHA256: cryptoutil.SHA256(cryptoutil.SHA1("2910d03d-c0b5-4f71-bad5-c4086e4efae3")), CreatedUnix: 1588568886, UpdatedUnix: 1588572486, // 1 hour later }, @@ -70,12 +71,21 @@ func setupDBToDump(t *testing.T, db *gorm.DB) { UserID: 1, Name: "test2", Sha1: cryptoutil.SHA1("84117e17-7e67-4024-bd04-1c23e6e809d4"), + SHA256: cryptoutil.SHA256(cryptoutil.SHA1("84117e17-7e67-4024-bd04-1c23e6e809d4")), CreatedUnix: 1588568886, }, &AccessToken{ UserID: 2, Name: "test1", Sha1: cryptoutil.SHA1("da2775ce-73dd-47ba-b9d2-bbcc346585c4"), + SHA256: cryptoutil.SHA256(cryptoutil.SHA1("da2775ce-73dd-47ba-b9d2-bbcc346585c4")), + CreatedUnix: 1588568886, + }, + &AccessToken{ + UserID: 2, + Name: "test2", + Sha1: cryptoutil.SHA256(cryptoutil.SHA1("1b2dccd1-a262-470f-bb8c-7fc73192e9bb"))[:40], + SHA256: cryptoutil.SHA256(cryptoutil.SHA1("1b2dccd1-a262-470f-bb8c-7fc73192e9bb")), CreatedUnix: 1588568886, }, |