-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make vault key a param and start adding some unit tests
- Loading branch information
1 parent
cd6d338
commit 570d2b4
Showing
3 changed files
with
69 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pytest | ||
|
||
from presidio_anonymizer.entities import InvalidParamException | ||
from operators.vault import VaultEncrypt, VaultDecrypt | ||
|
||
|
||
class TestVaultEncrypt: | ||
def test_given_valid_key_raises_no_exceptions(self): | ||
VaultEncrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": "foobar"}) | ||
|
||
def test_given_invalid_key_raises_exceptions(self): | ||
with pytest.raises( | ||
InvalidParamException, | ||
match="Invalid input, key must be a valid encryption key name.", | ||
): | ||
VaultEncrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": 1}) | ||
|
||
def test_given_valid_url_raises_no_exceptions(self): | ||
VaultEncrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": "foobar"}) | ||
|
||
def test_given_invalid_url_raises_exceptions(self): | ||
with pytest.raises( | ||
InvalidParamException, | ||
match="Invalid input, vault_url must be a valid URL.", | ||
): | ||
VaultEncrypt().validate(params={"vault_url": "http:/127.0.0.1:8200", "key": "foobar"}) | ||
|
||
class TestVaultDecrypt: | ||
def test_given_valid_key_raises_no_exceptions(self): | ||
VaultDecrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": "foobar"}) | ||
|
||
def test_given_invalid_key_raises_exceptions(self): | ||
with pytest.raises( | ||
InvalidParamException, | ||
match="Invalid input, key must be a valid encryption key name.", | ||
): | ||
VaultDecrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": 1}) | ||
|
||
def test_given_valid_url_raises_no_exceptions(self): | ||
VaultDecrypt().validate(params={"vault_url": "http://127.0.0.1:8200", "key": "foobar"}) | ||
|
||
def test_given_invalid_url_raises_exceptions(self): | ||
with pytest.raises( | ||
InvalidParamException, | ||
match="Invalid input, vault_url must be a valid URL.", | ||
): | ||
VaultDecrypt().validate(params={"vault_url": "http:/127.0.0.1:8200", "key": "foobar"}) |