-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from EUDAT-B2SAFE/devel
Transfer changes for 1.0.1 to master
- Loading branch information
Showing
12 changed files
with
116 additions
and
34 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,26 @@ | ||
import sys | ||
if sys.version_info < (2, 7): | ||
import unittest2 as unittest | ||
else: | ||
import unittest | ||
|
||
from b2handle.utilconfig import get_valid_https_verify | ||
|
||
|
||
class UtilConfigTestCase(unittest.TestCase): | ||
|
||
def test_valid_https_verify_bool_true(self): | ||
"""Test return bool True when getting bool True""" | ||
self.assertEqual(get_valid_https_verify(True), True) | ||
|
||
def test_valid_https_verify_string_true(self): | ||
"""Test return bool True when getting string True""" | ||
self.assertEqual(get_valid_https_verify('True'), True) | ||
|
||
def test_valid_https_verify_string_false(self): | ||
"""Test return bool False when getting string False""" | ||
self.assertEqual(get_valid_https_verify('False'), False) | ||
|
||
def test_valid_https_verify_bool_string(self): | ||
"""Test return string when getting a string value in https_verify""" | ||
self.assertEqual(get_valid_https_verify('ca_cert.crt'), 'ca_cert.crt') |
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 @@ | ||
''' | ||
This module provides functions to parse | ||
and validate b2handle configuration | ||
''' | ||
|
||
def get_valid_https_verify(value): | ||
''' | ||
Get a value that can be the boolean representation of a string | ||
or a boolean itself and returns It as a boolean. | ||
If this is not the case, It returns a string. | ||
:value: The HTTPS_verify input value. A string can be passed as a path | ||
to a CA_BUNDLE certificate | ||
:returns: True, False or a string. | ||
''' | ||
http_verify_value = value | ||
bool_values = {'false': False, 'true': True} | ||
|
||
if isinstance(value, bool): | ||
http_verify_value = value | ||
elif isinstance(value, str) and value.lower() in bool_values.keys(): | ||
http_verify_value = bool_values[value.lower()] | ||
|
||
return http_verify_value |
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