-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .client import ( | ||
KeepassClient, | ||
PassClient | ||
) |
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,33 @@ | ||
import os | ||
|
||
from automon import log | ||
|
||
logger = log.logging.getLogger(__name__) | ||
logger.setLevel(level=log.DEBUG) | ||
|
||
|
||
class KeepassClient(object): | ||
|
||
def __init__(self): | ||
self.database_csv_path = None | ||
|
||
def set_database_csv_path(self, database_csv_path: str) -> bool: | ||
if os.path.exists(database_csv_path): | ||
self.database_csv_path = database_csv_path | ||
logger.debug( | ||
f'KeepassClient :: set_database_csv_path :: {database_csv_path} :: {os.stat(database_csv_path)}') | ||
return True | ||
|
||
raise FileNotFoundError(f'KeepassClient :: set_database_csv_path :: ERROR :: {database_csv_path}') | ||
|
||
def read_database_csv(self, database_csv_path: str) -> open: | ||
if self.set_database_csv_path(database_csv_path=database_csv_path): | ||
logger.debug(f'KeepassClient :: read_database_csv :: open') | ||
return open(self.database_csv_path, 'r').read() | ||
|
||
raise OSError(f'KeepassClient :: read_database_csv :: ERROR :: {database_csv_path}') | ||
|
||
|
||
|
||
class PassClient(object): | ||
pass |
Empty file.
23 changes: 23 additions & 0 deletions
23
automon/integrations/keepass_to_pass/tests/test_keepass.py
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,23 @@ | ||
import unittest | ||
|
||
from automon.integrations.keepass_to_pass import KeepassClient | ||
|
||
|
||
class TestKeepassClient(unittest.TestCase): | ||
def test_set_database_csv_path(self): | ||
test = KeepassClient() | ||
with self.assertRaises(FileNotFoundError): | ||
test.set_database_csv_path('AAAA.XXXCSV') | ||
|
||
open('BBBB.XXXCSV', 'w').close() | ||
|
||
self.assertTrue(test.set_database_csv_path('BBBB.XXXCSV')) | ||
|
||
def test_read_database_csv(self): | ||
test = KeepassClient() | ||
with self.assertRaises(OSError): | ||
test.read_database_csv('AAAA.XXXCSV') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |