Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer security file over username/password #21

Merged
merged 1 commit into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ StorOps: The Python Library for VNX & Unity
.. image:: https://img.shields.io/pypi/v/storops.svg
:target: https://pypi.python.org/pypi/storops

VERSION: 0.2.18
VERSION: 0.2.19

A minimalist Python library to manage VNX/Unity systems.
This document lies in the source code and go with the release.
Expand Down Expand Up @@ -312,6 +312,8 @@ EMC Contributors
Community Contributors
``````````````````````

- Paulo Matias <[email protected]>

Patches and Suggestions
```````````````````````

Expand Down
9 changes: 4 additions & 5 deletions storops/vnx/navi_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ def is_credential_valid(self):
return self._is_credential_valid

def get_credentials(self):
if self._username is None and self._password is None:
if self._sec_file is not None:
# use security file
if self._sec_file is not None:
ret = text_var('-secfilepath', self._sec_file)
else:
ret = []
ret = text_var('-secfilepath', self._sec_file)
elif self._username is None and self._password is None:
ret = []
elif self._username is None or self._password is None:
self._is_credential_valid = False
raise ex.VNXCredentialError('username or password missing.')
Expand Down
7 changes: 7 additions & 0 deletions test/vnx/test_navi_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def test_security_file(self):
assert_that(' '.join(cmd.get_credentials()),
equal_to('-secfilepath /a/b/c.key'))

@patch_cli
def test_security_file_precedence(self):
cmd = NaviCommand(sec_file=r'/a/b/c.key',
username='admin', password='')
assert_that(' '.join(cmd.get_credentials()),
equal_to('-secfilepath /a/b/c.key'))

@patch_cli
def test_username_password_timeout(self):
cmd = NaviCommand('a', 'a', 1, timeout=20)
Expand Down