| 10 | |
| 11 | @dataclass |
| 12 | class Test(): |
| 13 | session: Any |
| 14 | project: Any = None |
| 15 | |
| 16 | def __post_init__(self): |
| 17 | |
| 18 | self.log = regular_log.default() |
| 19 | self.try_to_commit = regular_methods.try_to_commit |
| 20 | |
| 21 | |
| 22 | def mock_decryption(self): |
| 23 | |
| 24 | import difflib |
| 25 | |
| 26 | connection_id = 10 |
| 27 | |
| 28 | connection_operations = Connection_Operations( |
| 29 | session = self.session, |
| 30 | connection_id = connection_id |
| 31 | ) |
| 32 | |
| 33 | connection_operations.get_existing_connection(connection_id) |
| 34 | |
| 35 | print(connection_operations.connection.private_secret_encrypted) |
| 36 | |
| 37 | decrypted_secret = connection_operations.get_secret() |
| 38 | |
| 39 | assert connection_operations.connection.private_secret_encrypted != decrypted_secret |
| 40 | |
| 41 | sandbox_key = "\n" |
| 42 | def diff(a, b): |
| 43 | for i,s in enumerate(difflib.ndiff(a, b)): |
| 44 | if s[0]==' ': continue |
| 45 | elif s[0]=='-': |
| 46 | print(f'Delete "{s[-1]}" from position {i}') |
| 47 | elif s[0]=='+': |
| 48 | print(f'Add "{s[-1]}" to position {i}') |
| 49 | |
| 50 | # Diff falsely fails here.... |
| 51 | |
| 52 | #diff(decrypted_secret, sandbox_key) |
| 53 | # https://stackoverflow.com/questions/46280148/python-3-x-dont-count-carriage-returns-with-len |
| 54 | # assert with carraige returns? |
| 55 | |
| 56 | print(len(decrypted_secret), len(sandbox_key)) |
| 57 | assert decrypted_secret == sandbox_key |
| 58 | #assert decrypted_secret == "test" |
| 59 | |
| 60 | |
| 61 | |
| 62 | def mock_source(self, id): |
| 63 | """ |
| 64 | """ |
| 65 | project_string_id = None |
| 66 | scope = None |
| 67 | private_secret = "Super secret" |
| 68 | private_id = "1" |
| 69 | |