-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(basic-auth) rename password hashing function
This commit simply updates the function names used to generated the SHA1 of the basic-auth credential's password to correctly identify the function's purpose and result. This lays the groundwork to be able to use symmetric encryption within Kong at large, without being confused by the legacy functionality present here. From #4170
- Loading branch information
1 parent
c7b6bdc
commit fe83467
Showing
5 changed files
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
local crypto = require "kong.plugins.basic-auth.crypto" | ||
|
||
describe("Plugin: basic-auth (crypto)", function() | ||
it("encrypts a credential with consumer_id salt", function() | ||
local value = crypto.encrypt("id123", "pass123") | ||
it("hashs a credential with consumer_id salt", function() | ||
local value = crypto.hash("id123", "pass123") | ||
assert.is_string(value) | ||
assert.equals(40, #value) | ||
assert.equals(crypto.encrypt("id123", "pass123"), crypto.encrypt("id123", "pass123")) | ||
assert.equals(crypto.hash("id123", "pass123"), crypto.hash("id123", "pass123")) | ||
end) | ||
|
||
it("substitutes empty string for password equal to nil", function() | ||
assert.equals(crypto.encrypt("id123"), crypto.encrypt("id123", "")) | ||
assert.equals(crypto.hash("id123"), crypto.hash("id123", "")) | ||
end) | ||
|
||
it("substitutes empty string for password equal to ngx.null", function() | ||
assert.equals(crypto.encrypt("id123"), crypto.encrypt("id123", ngx.null)) | ||
assert.equals(crypto.hash("id123"), crypto.hash("id123", ngx.null)) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters