This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hash password for IAAS/PAAS before sending then to the API.
By hashing the pwd the API won't be able to check/validate the password strength thus avoiding breaking the CLI when the rules change as it's currently the case with the gen-password option.
- Loading branch information
MoiTux
committed
Sep 15, 2018
1 parent
be0df58
commit 41646b1
Showing
6 changed files
with
91 additions
and
14 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from ..core.utils.password import hash_password | ||
from .compat import unittest, mock | ||
|
||
|
||
class TestHashPwd(unittest.TestCase): | ||
|
||
@mock.patch('gandi.cli.core.utils.password.mkpassword') | ||
def test_hash_pwd(self, mkpassword): | ||
mkpassword.return_value = 'aSaltSting.12345' | ||
|
||
self.assertEqual(hash_password('.aPwd42!'), | ||
'$6$aSaltSting.12345$' | ||
'kQ0e3QAP5MxJA4un4xkGCK4OwMc5dX/xKubYypmasAb' | ||
'U6ptnq5vyPi8IDfPm9zsKrUMKHhL056bD5rXsZqAt6.') | ||
|
||
def test_pwd_hashed(self): | ||
pwd = ('$6$aSaltSting.12345$' | ||
'kQ0e3QAP5MxJA4un4xkGCK4OwMc5dX/xKubYypmasAb' | ||
'U6ptnq5vyPi8IDfPm9zsKrUMKHhL056bD5rXsZqAt6.') | ||
|
||
self.assertEqual(hash_password(pwd), pwd) |