61f4c67ce11a1dd77b59613e550822d64877c904
Marco Ricci Change the author e-mail ad...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py       1) # SPDX-FileCopyrightText: 2024 Marco Ricci <software@the13thletter.info>
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py       2) #
tests/test_derivepassphrase_exporter_cli.py       3) # SPDX-License-Identifier: MIT
tests/test_derivepassphrase_exporter_cli.py       4) 
tests/test_derivepassphrase_exporter_cli.py       5) from __future__ import annotations
tests/test_derivepassphrase_exporter_cli.py       6) 
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py       7) import base64
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py       8) import json
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py       9) from typing import TYPE_CHECKING
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      10) 
tests/test_derivepassphrase_exporter_cli.py      11) import click.testing
tests/test_derivepassphrase_exporter_cli.py      12) import pytest
tests/test_derivepassphrase_exporter_cli.py      13) 
tests/test_derivepassphrase_exporter_cli.py      14) import tests
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py  15) from derivepassphrase import cli
tests/test_derivepassphrase_cli_export_vault.py  16) from derivepassphrase.exporter import storeroom, vault_native
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      17) 
tests/test_derivepassphrase_exporter_cli.py      18) cryptography = pytest.importorskip('cryptography', minversion='38.0')
tests/test_derivepassphrase_exporter_cli.py      19) 
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      20) if TYPE_CHECKING:
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      21)     from collections.abc import Callable
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      22)     from typing import Any
tests/test_derivepassphrase_exporter_cli.py      23) 
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      24) 
tests/test_derivepassphrase_exporter_cli.py      25) class TestCLI:
tests/test_derivepassphrase_exporter_cli.py      26)     def test_200_path_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:
tests/test_derivepassphrase_exporter_cli.py      27)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py      28)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py      29)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py      30)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py      31)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      32)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py      33)         ):
tests/test_derivepassphrase_exporter_cli.py      34)             monkeypatch.setenv('VAULT_KEY', tests.VAULT_MASTER_KEY)
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      35)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py  36)                 cli.derivepassphrase_export_vault,
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      37)                 ['VAULT_PATH'],
tests/test_derivepassphrase_exporter_cli.py      38)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      39)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py      40)         assert result.clean_exit(empty_stderr=True), 'expected clean exit'
tests/test_derivepassphrase_exporter_cli.py      41)         assert json.loads(result.output) == tests.VAULT_V03_CONFIG_DATA
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      42) 
tests/test_derivepassphrase_exporter_cli.py      43)     def test_201_key_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:
tests/test_derivepassphrase_exporter_cli.py      44)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py      45)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py      46)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py      47)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py      48)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      49)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      50)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py  51)                 cli.derivepassphrase_export_vault,
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      52)                 ['-k', tests.VAULT_MASTER_KEY, '.vault'],
tests/test_derivepassphrase_exporter_cli.py      53)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      54)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py      55)         assert result.clean_exit(empty_stderr=True), 'expected clean exit'
tests/test_derivepassphrase_exporter_cli.py      56)         assert json.loads(result.output) == tests.VAULT_V03_CONFIG_DATA
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      57) 
tests/test_derivepassphrase_exporter_cli.py      58)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py      59)         ['format', 'config', 'config_data'],
tests/test_derivepassphrase_exporter_cli.py      60)         [
tests/test_derivepassphrase_exporter_cli.py      61)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      62)                 'v0.2',
tests/test_derivepassphrase_exporter_cli.py      63)                 tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      64)                 tests.VAULT_V02_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      65)                 id='0.2',
tests/test_derivepassphrase_exporter_cli.py      66)             ),
tests/test_derivepassphrase_exporter_cli.py      67)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      68)                 'v0.3',
tests/test_derivepassphrase_exporter_cli.py      69)                 tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      70)                 tests.VAULT_V03_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      71)                 id='0.3',
tests/test_derivepassphrase_exporter_cli.py      72)             ),
tests/test_derivepassphrase_exporter_cli.py      73)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      74)                 'storeroom',
tests/test_derivepassphrase_exporter_cli.py      75)                 tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py      76)                 tests.VAULT_STOREROOM_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      77)                 id='storeroom',
tests/test_derivepassphrase_exporter_cli.py      78)             ),
tests/test_derivepassphrase_exporter_cli.py      79)         ],
tests/test_derivepassphrase_exporter_cli.py      80)     )
tests/test_derivepassphrase_exporter_cli.py      81)     def test_210_load_vault_v02_v03_storeroom(
tests/test_derivepassphrase_exporter_cli.py      82)         self,
tests/test_derivepassphrase_exporter_cli.py      83)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py      84)         format: str,
tests/test_derivepassphrase_exporter_cli.py      85)         config: str | bytes,
tests/test_derivepassphrase_exporter_cli.py      86)         config_data: dict[str, Any],
tests/test_derivepassphrase_exporter_cli.py      87)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py      88)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py      89)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py      90)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py      91)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py      92)             vault_config=config,
tests/test_derivepassphrase_exporter_cli.py      93)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      94)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py  95)                 cli.derivepassphrase_export_vault,
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      96)                 ['-f', format, '-k', tests.VAULT_MASTER_KEY, 'VAULT_PATH'],
tests/test_derivepassphrase_exporter_cli.py      97)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py      98)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py      99)         assert result.clean_exit(empty_stderr=True), 'expected clean exit'
tests/test_derivepassphrase_exporter_cli.py     100)         assert json.loads(result.output) == config_data
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     101) 
tests/test_derivepassphrase_exporter_cli.py     102)     # test_300_invalid_format is found in
tests/test_derivepassphrase_exporter_cli.py     103)     # tests.test_derivepassphrase_export::Test002CLI
tests/test_derivepassphrase_exporter_cli.py     104) 
tests/test_derivepassphrase_exporter_cli.py     105)     def test_301_vault_config_not_found(
tests/test_derivepassphrase_exporter_cli.py     106)         self,
tests/test_derivepassphrase_exporter_cli.py     107)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     108)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     109)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     110)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     111)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     112)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     113)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     114)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     115)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     116)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py 117)                 cli.derivepassphrase_export_vault,
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     118)                 ['does-not-exist.txt'],
tests/test_derivepassphrase_exporter_cli.py     119)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     120)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     121)         assert result.error_exit(
tests/test_derivepassphrase_exporter_cli.py     122)             error="Cannot parse 'does-not-exist.txt' as a valid config"
tests/test_derivepassphrase_exporter_cli.py     123)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     124)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     125) 
tests/test_derivepassphrase_exporter_cli.py     126)     def test_302_vault_config_invalid(
tests/test_derivepassphrase_exporter_cli.py     127)         self,
tests/test_derivepassphrase_exporter_cli.py     128)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     129)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     130)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     131)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     132)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     133)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     134)             vault_config='',
tests/test_derivepassphrase_exporter_cli.py     135)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     136)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     137)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py 138)                 cli.derivepassphrase_export_vault,
Marco Ricci Move exporter command-line...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     139)                 ['.vault'],
tests/test_derivepassphrase_exporter_cli.py     140)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     141)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     142)         assert result.error_exit(
tests/test_derivepassphrase_exporter_cli.py     143)             error="Cannot parse '.vault' as a valid config"
tests/test_derivepassphrase_exporter_cli.py     144)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     145)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     146) 
tests/test_derivepassphrase_exporter_cli.py     147)     def test_403_invalid_vault_config_bad_signature(
tests/test_derivepassphrase_exporter_cli.py     148)         self,
tests/test_derivepassphrase_exporter_cli.py     149)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     150)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     151)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     152)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     153)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     154)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     155)             vault_config=tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     156)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     157)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     158)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py 159)                 cli.derivepassphrase_export_vault,
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     160)                 ['-f', 'v0.3', '.vault'],
tests/test_derivepassphrase_exporter_cli.py     161)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     162)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     163)         assert result.error_exit(
tests/test_derivepassphrase_exporter_cli.py     164)             error="Cannot parse '.vault' as a valid config"
tests/test_derivepassphrase_exporter_cli.py     165)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     166)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     167) 
tests/test_derivepassphrase_exporter_cli.py     168)     def test_500_vault_config_invalid_internal(
tests/test_derivepassphrase_exporter_cli.py     169)         self,
tests/test_derivepassphrase_exporter_cli.py     170)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     171)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     172)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     173)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     174)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     175)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     176)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     177)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     178)         ):
tests/test_derivepassphrase_exporter_cli.py     179) 
tests/test_derivepassphrase_exporter_cli.py     180)             def _load_data(*_args: Any, **_kwargs: Any) -> None:
tests/test_derivepassphrase_exporter_cli.py     181)                 return None
tests/test_derivepassphrase_exporter_cli.py     182) 
tests/test_derivepassphrase_exporter_cli.py     183)             monkeypatch.setattr(cli, '_load_data', _load_data)
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     184)             _result = runner.invoke(
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_cli_export_vault.py 185)                 cli.derivepassphrase_export_vault,
Marco Ricci Test exporter data loading...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     186)                 ['.vault'],
tests/test_derivepassphrase_exporter_cli.py     187)             )
Marco Ricci Clean up testing machinery...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     188)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     189)         assert result.error_exit(
tests/test_derivepassphrase_exporter_cli.py     190)             error='Invalid vault config: '
tests/test_derivepassphrase_exporter_cli.py     191)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     192)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Add more tests of the store...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     193) 
tests/test_derivepassphrase_exporter_cli.py     194) 
tests/test_derivepassphrase_exporter_cli.py     195) class TestStoreroom:
tests/test_derivepassphrase_exporter_cli.py     196)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     197)         ['path', 'key'],
tests/test_derivepassphrase_exporter_cli.py     198)         [
tests/test_derivepassphrase_exporter_cli.py     199)             ('.vault', tests.VAULT_MASTER_KEY),
tests/test_derivepassphrase_exporter_cli.py     200)             ('.vault', None),
tests/test_derivepassphrase_exporter_cli.py     201)             (None, tests.VAULT_MASTER_KEY),
tests/test_derivepassphrase_exporter_cli.py     202)             (None, None),
tests/test_derivepassphrase_exporter_cli.py     203)         ],
tests/test_derivepassphrase_exporter_cli.py     204)     )
tests/test_derivepassphrase_exporter_cli.py     205)     def test_200_export_data_path_and_keys_type(
tests/test_derivepassphrase_exporter_cli.py     206)         self,
tests/test_derivepassphrase_exporter_cli.py     207)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     208)         path: str | None,
tests/test_derivepassphrase_exporter_cli.py     209)         key: str | None,
tests/test_derivepassphrase_exporter_cli.py     210)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     211)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     212)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     213)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     214)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     215)             vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py     216)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     217)         ):
tests/test_derivepassphrase_exporter_cli.py     218)             assert (
tests/test_derivepassphrase_exporter_cli.py     219)                 storeroom.export_storeroom_data(path, key)
tests/test_derivepassphrase_exporter_cli.py     220)                 == tests.VAULT_STOREROOM_CONFIG_DATA
tests/test_derivepassphrase_exporter_cli.py     221)             )
tests/test_derivepassphrase_exporter_cli.py     222) 
tests/test_derivepassphrase_exporter_cli.py     223)     def test_400_decrypt_bucket_item_unknown_version(self) -> None:
tests/test_derivepassphrase_exporter_cli.py     224)         bucket_item = (
tests/test_derivepassphrase_exporter_cli.py     225)             b'\xff' + bytes(storeroom.ENCRYPTED_KEYPAIR_SIZE) + bytes(3)
tests/test_derivepassphrase_exporter_cli.py     226)         )
tests/test_derivepassphrase_exporter_cli.py     227)         master_keys: storeroom.MasterKeys = {
tests/test_derivepassphrase_exporter_cli.py     228)             'encryption_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     229)             'signing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     230)             'hashing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     231)         }
Marco Ricci Apply new ruff ruleset to c...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     232)         with pytest.raises(ValueError, match='Cannot handle version 255'):
Marco Ricci Add more tests of the store...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     233)             storeroom.decrypt_bucket_item(bucket_item, master_keys)
tests/test_derivepassphrase_exporter_cli.py     234) 
tests/test_derivepassphrase_exporter_cli.py     235)     @pytest.mark.parametrize('config', ['xxx', 'null', '{"version": 255}'])
tests/test_derivepassphrase_exporter_cli.py     236)     def test_401_decrypt_bucket_file_bad_json_or_version(
tests/test_derivepassphrase_exporter_cli.py     237)         self,
tests/test_derivepassphrase_exporter_cli.py     238)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     239)         config: str,
tests/test_derivepassphrase_exporter_cli.py     240)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     241)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     242)         master_keys: storeroom.MasterKeys = {
tests/test_derivepassphrase_exporter_cli.py     243)             'encryption_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     244)             'signing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     245)             'hashing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     246)         }
tests/test_derivepassphrase_exporter_cli.py     247)         with (
tests/test_derivepassphrase_exporter_cli.py     248)             tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     249)                 monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     250)                 runner=runner,
tests/test_derivepassphrase_exporter_cli.py     251)                 vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py     252)             ),
tests/test_derivepassphrase_exporter_cli.py     253)         ):
tests/test_derivepassphrase_exporter_cli.py     254)             with open('.vault/20', 'w', encoding='UTF-8') as outfile:
tests/test_derivepassphrase_exporter_cli.py     255)                 print(config, file=outfile)
Marco Ricci Apply new ruff ruleset to c...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     256)             with pytest.raises(ValueError, match='Invalid bucket file: '):
Marco Ricci Add more tests of the store...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     257)                 list(storeroom.decrypt_bucket_file('.vault/20', master_keys))
tests/test_derivepassphrase_exporter_cli.py     258) 
tests/test_derivepassphrase_exporter_cli.py     259)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     260)         ['data', 'err_msg'],
tests/test_derivepassphrase_exporter_cli.py     261)         [
tests/test_derivepassphrase_exporter_cli.py     262)             ('{"version": 255}', 'bad or unsupported keys version header'),
tests/test_derivepassphrase_exporter_cli.py     263)             ('{"version": 1}\nAAAA\nAAAA', 'trailing data; cannot make sense'),
tests/test_derivepassphrase_exporter_cli.py     264)             ('{"version": 1}\nAAAA', 'cannot handle version 0 encrypted keys'),
tests/test_derivepassphrase_exporter_cli.py     265)         ],
tests/test_derivepassphrase_exporter_cli.py     266)     )
tests/test_derivepassphrase_exporter_cli.py     267)     def test_402_export_storeroom_data_bad_master_keys_file(
tests/test_derivepassphrase_exporter_cli.py     268)         self,
tests/test_derivepassphrase_exporter_cli.py     269)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     270)         data: str,
tests/test_derivepassphrase_exporter_cli.py     271)         err_msg: str,
tests/test_derivepassphrase_exporter_cli.py     272)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     273)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     274)         with (
tests/test_derivepassphrase_exporter_cli.py     275)             tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     276)                 monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     277)                 runner=runner,
tests/test_derivepassphrase_exporter_cli.py     278)                 vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py     279)                 vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     280)             ),
tests/test_derivepassphrase_exporter_cli.py     281)         ):
tests/test_derivepassphrase_exporter_cli.py     282)             with open('.vault/.keys', 'w', encoding='UTF-8') as outfile:
tests/test_derivepassphrase_exporter_cli.py     283)                 print(data, file=outfile)
tests/test_derivepassphrase_exporter_cli.py     284)             with pytest.raises(RuntimeError, match=err_msg):
tests/test_derivepassphrase_exporter_cli.py     285)                 storeroom.export_storeroom_data()
tests/test_derivepassphrase_exporter_cli.py     286) 
tests/test_derivepassphrase_exporter_cli.py     287)     def test_403_export_storeroom_data_bad_directory_listing(
tests/test_derivepassphrase_exporter_cli.py     288)         self,
tests/test_derivepassphrase_exporter_cli.py     289)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     290)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     291)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     292)         with (
tests/test_derivepassphrase_exporter_cli.py     293)             tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     294)                 monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     295)                 runner=runner,
tests/test_derivepassphrase_exporter_cli.py     296)                 vault_config=tests.VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py     297)                 vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     298)             ),
tests/test_derivepassphrase_exporter_cli.py     299)             pytest.raises(RuntimeError, match='Object key mismatch'),
tests/test_derivepassphrase_exporter_cli.py     300)         ):
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     301)             storeroom.export_storeroom_data()
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     302) 
tests/test_derivepassphrase_exporter_cli.py     303) 
tests/test_derivepassphrase_exporter_cli.py     304) class TestVaultNativeConfig:
tests/test_derivepassphrase_exporter_cli.py     305)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     306)         ['iterations', 'result'],
tests/test_derivepassphrase_exporter_cli.py     307)         [
tests/test_derivepassphrase_exporter_cli.py     308)             (100, b'6ede361e81e9c061efcdd68aeb768b80'),
tests/test_derivepassphrase_exporter_cli.py     309)             (200, b'bcc7d01e075b9ffb69e702bf701187c1'),
tests/test_derivepassphrase_exporter_cli.py     310)         ],
tests/test_derivepassphrase_exporter_cli.py     311)     )
tests/test_derivepassphrase_exporter_cli.py     312)     def test_200_pbkdf2_manually(self, iterations: int, result: bytes) -> None:
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     313)         assert (
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     314)             vault_native.VaultNativeConfigParser._pbkdf2(
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     315)                 tests.VAULT_MASTER_KEY.encode('utf-8'), 32, iterations
tests/test_derivepassphrase_exporter_cli.py     316)             )
tests/test_derivepassphrase_exporter_cli.py     317)             == result
tests/test_derivepassphrase_exporter_cli.py     318)         )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     319) 
Marco Ricci Add vault_native exporter f...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     320)     def test_201_export_vault_native_data_no_arguments(
tests/test_derivepassphrase_exporter_cli.py     321)         self, monkeypatch: pytest.MonkeyPatch
tests/test_derivepassphrase_exporter_cli.py     322)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     323)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     324)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     325)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     326)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     327)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     328)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     329)         ):
tests/test_derivepassphrase_exporter_cli.py     330)             parsed_config = vault_native.export_vault_native_data(None)
tests/test_derivepassphrase_exporter_cli.py     331)         assert parsed_config == tests.VAULT_V03_CONFIG_DATA
tests/test_derivepassphrase_exporter_cli.py     332) 
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     333)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     334)         ['parser_class', 'config', 'result'],
tests/test_derivepassphrase_exporter_cli.py     335)         [
tests/test_derivepassphrase_exporter_cli.py     336)             pytest.param(
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     337)                 vault_native.VaultNativeV02ConfigParser,
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     338)                 tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     339)                 tests.VAULT_V02_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py     340)                 id='0.2',
tests/test_derivepassphrase_exporter_cli.py     341)             ),
tests/test_derivepassphrase_exporter_cli.py     342)             pytest.param(
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     343)                 vault_native.VaultNativeV03ConfigParser,
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     344)                 tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     345)                 tests.VAULT_V03_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py     346)                 id='0.3',
tests/test_derivepassphrase_exporter_cli.py     347)             ),
tests/test_derivepassphrase_exporter_cli.py     348)         ],
tests/test_derivepassphrase_exporter_cli.py     349)     )
tests/test_derivepassphrase_exporter_cli.py     350)     def test_300_result_caching(
tests/test_derivepassphrase_exporter_cli.py     351)         self,
tests/test_derivepassphrase_exporter_cli.py     352)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     353)         parser_class: type[vault_native.VaultNativeConfigParser],
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     354)         config: str,
tests/test_derivepassphrase_exporter_cli.py     355)         result: dict[str, Any],
tests/test_derivepassphrase_exporter_cli.py     356)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     357)         def null_func(name: str) -> Callable[..., None]:
tests/test_derivepassphrase_exporter_cli.py     358)             def func(*_args: Any, **_kwargs: Any) -> None:  # pragma: no cover
tests/test_derivepassphrase_exporter_cli.py     359)                 msg = f'disallowed and stubbed out function {name} called'
tests/test_derivepassphrase_exporter_cli.py     360)                 raise AssertionError(msg)
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     361) 
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     362)             return func
tests/test_derivepassphrase_exporter_cli.py     363) 
tests/test_derivepassphrase_exporter_cli.py     364)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     365)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     366)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     367)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     368)             vault_config=config,
tests/test_derivepassphrase_exporter_cli.py     369)         ):
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     370)             parser = parser_class(
tests/test_derivepassphrase_exporter_cli.py     371)                 base64.b64decode(config), tests.VAULT_MASTER_KEY
tests/test_derivepassphrase_exporter_cli.py     372)             )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     373)             assert parser() == result
tests/test_derivepassphrase_exporter_cli.py     374)             # Now stub out all functions used to calculate the above result.
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     375)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     376)                 parser, '_parse_contents', null_func('_parse_contents')
tests/test_derivepassphrase_exporter_cli.py     377)             )
tests/test_derivepassphrase_exporter_cli.py     378)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     379)                 parser, '_derive_keys', null_func('_derive_keys')
tests/test_derivepassphrase_exporter_cli.py     380)             )
tests/test_derivepassphrase_exporter_cli.py     381)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     382)                 parser, '_check_signature', null_func('_check_signature')
tests/test_derivepassphrase_exporter_cli.py     383)             )
tests/test_derivepassphrase_exporter_cli.py     384)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     385)                 parser, '_decrypt_payload', null_func('_decrypt_payload')
tests/test_derivepassphrase_exporter_cli.py     386)             )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     387)             assert parser() == result
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     388)             super_call = vault_native.VaultNativeConfigParser.__call__
Marco Ricci Fix formatting and linting...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     389)             assert super_call(parser) == result
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 2 months ago

tests/test_derivepassphrase_exporter_cli.py     390) 
tests/test_derivepassphrase_exporter_cli.py     391)     def test_400_no_password(self) -> None:
tests/test_derivepassphrase_exporter_cli.py     392)         with pytest.raises(ValueError, match='Password must not be empty'):