Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
f5359c31
Commit
f5359c31
authored
Feb 26, 2014
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add negative tests for VaultLib
parent
96f1c3ce
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
test/units/TestVault.py
+35
-0
No files found.
test/units/TestVault.py
View file @
f5359c31
...
@@ -11,6 +11,7 @@ from binascii import unhexlify
...
@@ -11,6 +11,7 @@ from binascii import unhexlify
from
binascii
import
hexlify
from
binascii
import
hexlify
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
ansible
import
errors
from
ansible.utils.vault
import
VaultLib
from
ansible.utils.vault
import
VaultLib
# AES IMPORTS
# AES IMPORTS
try
:
try
:
...
@@ -73,3 +74,37 @@ class TestVaultLib(TestCase):
...
@@ -73,3 +74,37 @@ class TestVaultLib(TestCase):
assert
enc_data
!=
"foobar"
,
"encryption failed"
assert
enc_data
!=
"foobar"
,
"encryption failed"
assert
dec_data
==
"foobar"
,
"decryption failed"
assert
dec_data
==
"foobar"
,
"decryption failed"
@unittest.skipIf
(
not
HAS_AES
,
"aes not installed"
)
def
test_encrypt_encrypted
(
self
):
v
=
VaultLib
(
'ansible'
)
v
.
cipher_name
=
'AES'
data
=
"$ANSIBLE_VAULT;9.9;TEST
\n
%
s"
%
hexlify
(
"ansible"
)
error_hit
=
False
try
:
enc_data
=
v
.
encrypt
(
data
)
except
errors
.
AnsibleError
,
e
:
error_hit
=
True
assert
error_hit
,
"No error was thrown when trying to encrypt data with a header"
def
test_decrypt_decrypted
(
self
):
v
=
VaultLib
(
'ansible'
)
data
=
"ansible"
error_hit
=
False
try
:
dec_data
=
v
.
decrypt
(
data
)
except
errors
.
AnsibleError
,
e
:
error_hit
=
True
assert
error_hit
,
"No error was thrown when trying to decrypt data without a header"
@unittest.skipIf
(
not
HAS_AES
,
"aes not installed"
)
def
test_cipher_not_set
(
self
):
v
=
VaultLib
(
'ansible'
)
data
=
"ansible"
error_hit
=
False
try
:
enc_data
=
v
.
encrypt
(
data
)
except
errors
.
AnsibleError
,
e
:
error_hit
=
True
assert
error_hit
,
"No error was thrown when trying to encrypt data without the cipher set"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment