1ec3538850a7af2723f17b8ca8dfe93158b421cb
Marco Ricci Change the author e-mail ad...

Marco Ricci authored 4 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 4 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 4 months ago

tests/test_derivepassphrase_exporter_cli.py       7) import base64
Marco Ricci Refactor code to run under...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py   8) import contextlib
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      11) 
tests/test_derivepassphrase_exporter_cli.py      12) import click.testing
Marco Ricci Trigger InvalidSignature ex...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py  13) import hypothesis
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      14) import pytest
Marco Ricci Trigger InvalidSignature ex...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py  15) from hypothesis import strategies
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      16) 
tests/test_derivepassphrase_exporter_cli.py      17) import tests
Marco Ricci Reintegrate all functionali...

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      20) 
tests/test_derivepassphrase_exporter_cli.py      21) cryptography = pytest.importorskip('cryptography', minversion='38.0')
tests/test_derivepassphrase_exporter_cli.py      22) 
Marco Ricci Add remaining tests to the...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py  23) from cryptography.hazmat.primitives import (  # noqa: E402
tests/test_derivepassphrase_cli_export_vault.py  24)     ciphers,
tests/test_derivepassphrase_cli_export_vault.py  25)     hashes,
tests/test_derivepassphrase_cli_export_vault.py  26)     hmac,
tests/test_derivepassphrase_cli_export_vault.py  27)     padding,
tests/test_derivepassphrase_cli_export_vault.py  28) )
tests/test_derivepassphrase_cli_export_vault.py  29) from cryptography.hazmat.primitives.ciphers import (  # noqa: E402
tests/test_derivepassphrase_cli_export_vault.py  30)     algorithms,
tests/test_derivepassphrase_cli_export_vault.py  31)     modes,
tests/test_derivepassphrase_cli_export_vault.py  32) )
tests/test_derivepassphrase_cli_export_vault.py  33) 
Marco Ricci Test exporter data loading...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      38) 
tests/test_derivepassphrase_exporter_cli.py      39) class TestCLI:
tests/test_derivepassphrase_exporter_cli.py      40)     def test_200_path_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:
tests/test_derivepassphrase_exporter_cli.py      41)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py      42)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py      43)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py      44)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py      45)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      46)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py      47)         ):
tests/test_derivepassphrase_exporter_cli.py      48)             monkeypatch.setenv('VAULT_KEY', tests.VAULT_MASTER_KEY)
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      56) 
tests/test_derivepassphrase_exporter_cli.py      57)     def test_201_key_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:
tests/test_derivepassphrase_exporter_cli.py      58)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py      59)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py      60)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py      61)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py      62)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      63)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py      71) 
tests/test_derivepassphrase_exporter_cli.py      72)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py      73)         ['format', 'config', 'config_data'],
tests/test_derivepassphrase_exporter_cli.py      74)         [
tests/test_derivepassphrase_exporter_cli.py      75)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      76)                 'v0.2',
tests/test_derivepassphrase_exporter_cli.py      77)                 tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      78)                 tests.VAULT_V02_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      79)                 id='0.2',
tests/test_derivepassphrase_exporter_cli.py      80)             ),
tests/test_derivepassphrase_exporter_cli.py      81)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      82)                 'v0.3',
tests/test_derivepassphrase_exporter_cli.py      83)                 tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py      84)                 tests.VAULT_V03_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      85)                 id='0.3',
tests/test_derivepassphrase_exporter_cli.py      86)             ),
tests/test_derivepassphrase_exporter_cli.py      87)             pytest.param(
tests/test_derivepassphrase_exporter_cli.py      88)                 'storeroom',
tests/test_derivepassphrase_exporter_cli.py      89)                 tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py      90)                 tests.VAULT_STOREROOM_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py      91)                 id='storeroom',
tests/test_derivepassphrase_exporter_cli.py      92)             ),
tests/test_derivepassphrase_exporter_cli.py      93)         ],
tests/test_derivepassphrase_exporter_cli.py      94)     )
tests/test_derivepassphrase_exporter_cli.py      95)     def test_210_load_vault_v02_v03_storeroom(
tests/test_derivepassphrase_exporter_cli.py      96)         self,
tests/test_derivepassphrase_exporter_cli.py      97)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py      98)         format: str,
tests/test_derivepassphrase_exporter_cli.py      99)         config: str | bytes,
tests/test_derivepassphrase_exporter_cli.py     100)         config_data: dict[str, Any],
tests/test_derivepassphrase_exporter_cli.py     101)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     102)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     103)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     104)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     105)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     106)             vault_config=config,
tests/test_derivepassphrase_exporter_cli.py     107)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     115) 
tests/test_derivepassphrase_exporter_cli.py     116)     # test_300_invalid_format is found in
tests/test_derivepassphrase_exporter_cli.py     117)     # tests.test_derivepassphrase_export::Test002CLI
tests/test_derivepassphrase_exporter_cli.py     118) 
tests/test_derivepassphrase_exporter_cli.py     119)     def test_301_vault_config_not_found(
tests/test_derivepassphrase_exporter_cli.py     120)         self,
tests/test_derivepassphrase_exporter_cli.py     121)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 122)         caplog: pytest.LogCaptureFixture,
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     123)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     124)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     125)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     126)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     127)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     128)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     129)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     130)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     135)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     136)         assert result.error_exit(
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 137)             error="Cannot parse 'does-not-exist.txt' as a valid config",
tests/test_derivepassphrase_cli_export_vault.py 138)             record_tuples=caplog.record_tuples,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     139)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     140)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     141) 
tests/test_derivepassphrase_exporter_cli.py     142)     def test_302_vault_config_invalid(
tests/test_derivepassphrase_exporter_cli.py     143)         self,
tests/test_derivepassphrase_exporter_cli.py     144)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 145)         caplog: pytest.LogCaptureFixture,
Marco Ricci Move exporter command-line...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     146)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     147)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     148)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     149)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     150)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     151)             vault_config='',
tests/test_derivepassphrase_exporter_cli.py     152)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     153)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     158)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     159)         assert result.error_exit(
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 160)             error="Cannot parse '.vault' as a valid config",
tests/test_derivepassphrase_cli_export_vault.py 161)             record_tuples=caplog.record_tuples,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     162)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     163)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Test exporter data loading...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     164) 
tests/test_derivepassphrase_exporter_cli.py     165)     def test_403_invalid_vault_config_bad_signature(
tests/test_derivepassphrase_exporter_cli.py     166)         self,
tests/test_derivepassphrase_exporter_cli.py     167)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 168)         caplog: pytest.LogCaptureFixture,
Marco Ricci Test exporter data loading...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     169)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     170)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     171)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     172)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     173)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     174)             vault_config=tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     175)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     176)         ):
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     181)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     182)         assert result.error_exit(
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 183)             error="Cannot parse '.vault' as a valid config",
tests/test_derivepassphrase_cli_export_vault.py 184)             record_tuples=caplog.record_tuples,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     185)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     186)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Test exporter data loading...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     187) 
tests/test_derivepassphrase_exporter_cli.py     188)     def test_500_vault_config_invalid_internal(
tests/test_derivepassphrase_exporter_cli.py     189)         self,
tests/test_derivepassphrase_exporter_cli.py     190)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 191)         caplog: pytest.LogCaptureFixture,
Marco Ricci Test exporter data loading...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     192)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     193)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     194)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     195)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     196)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     197)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     198)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     199)         ):
tests/test_derivepassphrase_exporter_cli.py     200) 
tests/test_derivepassphrase_exporter_cli.py     201)             def _load_data(*_args: Any, **_kwargs: Any) -> None:
tests/test_derivepassphrase_exporter_cli.py     202)                 return None
tests/test_derivepassphrase_exporter_cli.py     203) 
tests/test_derivepassphrase_exporter_cli.py     204)             monkeypatch.setattr(cli, '_load_data', _load_data)
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 3 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     209)         result = tests.ReadableResult.parse(_result)
tests/test_derivepassphrase_exporter_cli.py     210)         assert result.error_exit(
Marco Ricci Adapt the test suite to use...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 211)             error='Invalid vault config: ',
tests/test_derivepassphrase_cli_export_vault.py 212)             record_tuples=caplog.record_tuples,
Marco Ricci Clean up testing machinery...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     213)         ), 'expected error exit and known error message'
tests/test_derivepassphrase_exporter_cli.py     214)         assert tests.CANNOT_LOAD_CRYPTOGRAPHY not in result.stderr
Marco Ricci Add more tests of the store...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     215) 
tests/test_derivepassphrase_exporter_cli.py     216) 
tests/test_derivepassphrase_exporter_cli.py     217) class TestStoreroom:
tests/test_derivepassphrase_exporter_cli.py     218)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     219)         ['path', 'key'],
tests/test_derivepassphrase_exporter_cli.py     220)         [
tests/test_derivepassphrase_exporter_cli.py     221)             ('.vault', tests.VAULT_MASTER_KEY),
tests/test_derivepassphrase_exporter_cli.py     222)             ('.vault', None),
tests/test_derivepassphrase_exporter_cli.py     223)             (None, tests.VAULT_MASTER_KEY),
tests/test_derivepassphrase_exporter_cli.py     224)             (None, None),
tests/test_derivepassphrase_exporter_cli.py     225)         ],
tests/test_derivepassphrase_exporter_cli.py     226)     )
tests/test_derivepassphrase_exporter_cli.py     227)     def test_200_export_data_path_and_keys_type(
tests/test_derivepassphrase_exporter_cli.py     228)         self,
tests/test_derivepassphrase_exporter_cli.py     229)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     230)         path: str | None,
tests/test_derivepassphrase_exporter_cli.py     231)         key: str | None,
tests/test_derivepassphrase_exporter_cli.py     232)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     233)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     234)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     235)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     236)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     237)             vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_exporter_cli.py     238)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     239)         ):
tests/test_derivepassphrase_exporter_cli.py     240)             assert (
tests/test_derivepassphrase_exporter_cli.py     241)                 storeroom.export_storeroom_data(path, key)
tests/test_derivepassphrase_exporter_cli.py     242)                 == tests.VAULT_STOREROOM_CONFIG_DATA
tests/test_derivepassphrase_exporter_cli.py     243)             )
tests/test_derivepassphrase_exporter_cli.py     244) 
tests/test_derivepassphrase_exporter_cli.py     245)     def test_400_decrypt_bucket_item_unknown_version(self) -> None:
tests/test_derivepassphrase_exporter_cli.py     246)         bucket_item = (
tests/test_derivepassphrase_exporter_cli.py     247)             b'\xff' + bytes(storeroom.ENCRYPTED_KEYPAIR_SIZE) + bytes(3)
tests/test_derivepassphrase_exporter_cli.py     248)         )
tests/test_derivepassphrase_exporter_cli.py     249)         master_keys: storeroom.MasterKeys = {
tests/test_derivepassphrase_exporter_cli.py     250)             'encryption_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     251)             'signing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     252)             'hashing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     253)         }
Marco Ricci Apply new ruff ruleset to c...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     255)             storeroom.decrypt_bucket_item(bucket_item, master_keys)
tests/test_derivepassphrase_exporter_cli.py     256) 
tests/test_derivepassphrase_exporter_cli.py     257)     @pytest.mark.parametrize('config', ['xxx', 'null', '{"version": 255}'])
tests/test_derivepassphrase_exporter_cli.py     258)     def test_401_decrypt_bucket_file_bad_json_or_version(
tests/test_derivepassphrase_exporter_cli.py     259)         self,
tests/test_derivepassphrase_exporter_cli.py     260)         monkeypatch: pytest.MonkeyPatch,
tests/test_derivepassphrase_exporter_cli.py     261)         config: str,
tests/test_derivepassphrase_exporter_cli.py     262)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     263)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     264)         master_keys: storeroom.MasterKeys = {
tests/test_derivepassphrase_exporter_cli.py     265)             'encryption_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     266)             'signing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     267)             'hashing_key': bytes(storeroom.KEY_SIZE),
tests/test_derivepassphrase_exporter_cli.py     268)         }
Marco Ricci Refactor code to run under...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 269)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_cli_export_vault.py 270)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_cli_export_vault.py 271)             runner=runner,
tests/test_derivepassphrase_cli_export_vault.py 272)             vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
Marco Ricci Add more tests of the store...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     273)         ):
tests/test_derivepassphrase_exporter_cli.py     274)             with open('.vault/20', 'w', encoding='UTF-8') as outfile:
tests/test_derivepassphrase_exporter_cli.py     275)                 print(config, file=outfile)
Marco Ricci Apply new ruff ruleset to c...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     277)                 list(storeroom.decrypt_bucket_file('.vault/20', master_keys))
tests/test_derivepassphrase_exporter_cli.py     278) 
tests/test_derivepassphrase_exporter_cli.py     279)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     280)         ['data', 'err_msg'],
tests/test_derivepassphrase_exporter_cli.py     281)         [
tests/test_derivepassphrase_exporter_cli.py     282)             ('{"version": 255}', 'bad or unsupported keys version header'),
tests/test_derivepassphrase_exporter_cli.py     283)             ('{"version": 1}\nAAAA\nAAAA', 'trailing data; cannot make sense'),
tests/test_derivepassphrase_exporter_cli.py     284)             ('{"version": 1}\nAAAA', 'cannot handle version 0 encrypted keys'),
tests/test_derivepassphrase_exporter_cli.py     285)         ],
tests/test_derivepassphrase_exporter_cli.py     286)     )
tests/test_derivepassphrase_exporter_cli.py     287)     def test_402_export_storeroom_data_bad_master_keys_file(
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)         data: str,
tests/test_derivepassphrase_exporter_cli.py     291)         err_msg: str,
tests/test_derivepassphrase_exporter_cli.py     292)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     293)         runner = click.testing.CliRunner(mix_stderr=False)
Marco Ricci Refactor code to run under...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 294)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_cli_export_vault.py 295)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_cli_export_vault.py 296)             runner=runner,
tests/test_derivepassphrase_cli_export_vault.py 297)             vault_config=tests.VAULT_STOREROOM_CONFIG_ZIPPED,
tests/test_derivepassphrase_cli_export_vault.py 298)             vault_key=tests.VAULT_MASTER_KEY,
Marco Ricci Add more tests of the store...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     299)         ):
tests/test_derivepassphrase_exporter_cli.py     300)             with open('.vault/.keys', 'w', encoding='UTF-8') as outfile:
tests/test_derivepassphrase_exporter_cli.py     301)                 print(data, file=outfile)
tests/test_derivepassphrase_exporter_cli.py     302)             with pytest.raises(RuntimeError, match=err_msg):
tests/test_derivepassphrase_exporter_cli.py     303)                 storeroom.export_storeroom_data()
tests/test_derivepassphrase_exporter_cli.py     304) 
Marco Ricci Add remaining tests to the...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py 305)     @pytest.mark.parametrize(
tests/test_derivepassphrase_cli_export_vault.py 306)         ['zipped_config', 'error_text'],
tests/test_derivepassphrase_cli_export_vault.py 307)         [
tests/test_derivepassphrase_cli_export_vault.py 308)             pytest.param(
tests/test_derivepassphrase_cli_export_vault.py 309)                 tests.VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED,
tests/test_derivepassphrase_cli_export_vault.py 310)                 'Object key mismatch',
tests/test_derivepassphrase_cli_export_vault.py 311)                 id='VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED',
tests/test_derivepassphrase_cli_export_vault.py 312)             ),
tests/test_derivepassphrase_cli_export_vault.py 313)             pytest.param(
tests/test_derivepassphrase_cli_export_vault.py 314)                 tests.VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED2,
tests/test_derivepassphrase_cli_export_vault.py 315)                 'Directory index is not actually an index',
tests/test_derivepassphrase_cli_export_vault.py 316)                 id='VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED2',
tests/test_derivepassphrase_cli_export_vault.py 317)             ),
tests/test_derivepassphrase_cli_export_vault.py 318)             pytest.param(
tests/test_derivepassphrase_cli_export_vault.py 319)                 tests.VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED3,
tests/test_derivepassphrase_cli_export_vault.py 320)                 'Directory index is not actually an index',
tests/test_derivepassphrase_cli_export_vault.py 321)                 id='VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED3',
tests/test_derivepassphrase_cli_export_vault.py 322)             ),
tests/test_derivepassphrase_cli_export_vault.py 323)             pytest.param(
tests/test_derivepassphrase_cli_export_vault.py 324)                 tests.VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED4,
tests/test_derivepassphrase_cli_export_vault.py 325)                 'Object key mismatch',
tests/test_derivepassphrase_cli_export_vault.py 326)                 id='VAULT_STOREROOM_BROKEN_DIR_CONFIG_ZIPPED4',
tests/test_derivepassphrase_cli_export_vault.py 327)             ),
tests/test_derivepassphrase_cli_export_vault.py 328)         ],
tests/test_derivepassphrase_cli_export_vault.py 329)     )
Marco Ricci Add more tests of the store...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     330)     def test_403_export_storeroom_data_bad_directory_listing(
tests/test_derivepassphrase_exporter_cli.py     331)         self,
tests/test_derivepassphrase_exporter_cli.py     332)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Add remaining tests to the...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py 333)         zipped_config: bytes,
tests/test_derivepassphrase_cli_export_vault.py 334)         error_text: str,
Marco Ricci Add more tests of the store...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     335)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     336)         runner = click.testing.CliRunner(mix_stderr=False)
Marco Ricci Refactor code to run under...

Marco Ricci authored 1 month ago

tests/test_derivepassphrase_cli_export_vault.py 337)         # Use parenthesized context manager expressions once Python 3.9
tests/test_derivepassphrase_cli_export_vault.py 338)         # becomes unsupported.
tests/test_derivepassphrase_cli_export_vault.py 339)         with contextlib.ExitStack() as stack:
tests/test_derivepassphrase_cli_export_vault.py 340)             stack.enter_context(
tests/test_derivepassphrase_cli_export_vault.py 341)                 tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_cli_export_vault.py 342)                     monkeypatch=monkeypatch,
tests/test_derivepassphrase_cli_export_vault.py 343)                     runner=runner,
tests/test_derivepassphrase_cli_export_vault.py 344)                     vault_config=zipped_config,
tests/test_derivepassphrase_cli_export_vault.py 345)                     vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_cli_export_vault.py 346)                 )
tests/test_derivepassphrase_cli_export_vault.py 347)             )
tests/test_derivepassphrase_cli_export_vault.py 348)             stack.enter_context(pytest.raises(RuntimeError, match=error_text))
Marco Ricci Fix formatting and linting...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     350) 
Marco Ricci Add remaining tests to the...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py 351)     def test_404_decrypt_keys_wrong_data_length(self) -> None:
tests/test_derivepassphrase_cli_export_vault.py 352)         payload = (
tests/test_derivepassphrase_cli_export_vault.py 353)             b"Any text here, as long as it isn't "
tests/test_derivepassphrase_cli_export_vault.py 354)             b'exactly 64 or 96 bytes long.'
tests/test_derivepassphrase_cli_export_vault.py 355)         )
tests/test_derivepassphrase_cli_export_vault.py 356)         assert len(payload) not in frozenset({
tests/test_derivepassphrase_cli_export_vault.py 357)             2 * storeroom.KEY_SIZE,
tests/test_derivepassphrase_cli_export_vault.py 358)             3 * storeroom.KEY_SIZE,
tests/test_derivepassphrase_cli_export_vault.py 359)         })
tests/test_derivepassphrase_cli_export_vault.py 360)         key = b'DEADBEEFdeadbeefDeAdBeEfdEaDbEeF'
tests/test_derivepassphrase_cli_export_vault.py 361)         padder = padding.PKCS7(storeroom.IV_SIZE * 8).padder()
tests/test_derivepassphrase_cli_export_vault.py 362)         plaintext = bytearray(padder.update(payload))
tests/test_derivepassphrase_cli_export_vault.py 363)         plaintext.extend(padder.finalize())
tests/test_derivepassphrase_cli_export_vault.py 364)         iv = b'deadbeefDEADBEEF'
tests/test_derivepassphrase_cli_export_vault.py 365)         assert len(iv) == storeroom.IV_SIZE
tests/test_derivepassphrase_cli_export_vault.py 366)         encryptor = ciphers.Cipher(
tests/test_derivepassphrase_cli_export_vault.py 367)             algorithms.AES256(key), modes.CBC(iv)
tests/test_derivepassphrase_cli_export_vault.py 368)         ).encryptor()
tests/test_derivepassphrase_cli_export_vault.py 369)         ciphertext = bytearray(encryptor.update(plaintext))
tests/test_derivepassphrase_cli_export_vault.py 370)         ciphertext.extend(encryptor.finalize())
tests/test_derivepassphrase_cli_export_vault.py 371)         mac_obj = hmac.HMAC(key, hashes.SHA256())
tests/test_derivepassphrase_cli_export_vault.py 372)         mac_obj.update(iv)
tests/test_derivepassphrase_cli_export_vault.py 373)         mac_obj.update(ciphertext)
tests/test_derivepassphrase_cli_export_vault.py 374)         data = iv + bytes(ciphertext) + mac_obj.finalize()
tests/test_derivepassphrase_cli_export_vault.py 375)         with pytest.raises(
tests/test_derivepassphrase_cli_export_vault.py 376)             ValueError,
tests/test_derivepassphrase_cli_export_vault.py 377)             match=r'Invalid encrypted master keys payload',
tests/test_derivepassphrase_cli_export_vault.py 378)         ):
tests/test_derivepassphrase_cli_export_vault.py 379)             storeroom.decrypt_master_keys_data(
tests/test_derivepassphrase_cli_export_vault.py 380)                 data, {'encryption_key': key, 'signing_key': key}
tests/test_derivepassphrase_cli_export_vault.py 381)             )
tests/test_derivepassphrase_cli_export_vault.py 382)         with pytest.raises(
tests/test_derivepassphrase_cli_export_vault.py 383)             ValueError,
tests/test_derivepassphrase_cli_export_vault.py 384)             match=r'Invalid encrypted session keys payload',
tests/test_derivepassphrase_cli_export_vault.py 385)         ):
tests/test_derivepassphrase_cli_export_vault.py 386)             storeroom.decrypt_session_keys(
tests/test_derivepassphrase_cli_export_vault.py 387)                 data,
tests/test_derivepassphrase_cli_export_vault.py 388)                 {
tests/test_derivepassphrase_cli_export_vault.py 389)                     'hashing_key': key,
tests/test_derivepassphrase_cli_export_vault.py 390)                     'encryption_key': key,
tests/test_derivepassphrase_cli_export_vault.py 391)                     'signing_key': key,
tests/test_derivepassphrase_cli_export_vault.py 392)                 },
tests/test_derivepassphrase_cli_export_vault.py 393)             )
tests/test_derivepassphrase_cli_export_vault.py 394) 
Marco Ricci Trigger InvalidSignature ex...

Marco Ricci authored 3 months ago

tests/test_derivepassphrase_cli_export_vault.py 395)     @tests.hypothesis_settings_coverage_compatible
tests/test_derivepassphrase_cli_export_vault.py 396)     @hypothesis.given(
tests/test_derivepassphrase_cli_export_vault.py 397)         data=strategies.binary(
tests/test_derivepassphrase_cli_export_vault.py 398)             min_size=storeroom.MAC_SIZE, max_size=storeroom.MAC_SIZE
tests/test_derivepassphrase_cli_export_vault.py 399)         ),
tests/test_derivepassphrase_cli_export_vault.py 400)     )
tests/test_derivepassphrase_cli_export_vault.py 401)     def test_405_decrypt_keys_invalid_signature(self, data: bytes) -> None:
tests/test_derivepassphrase_cli_export_vault.py 402)         key = b'DEADBEEFdeadbeefDeAdBeEfdEaDbEeF'
tests/test_derivepassphrase_cli_export_vault.py 403)         # Guessing a correct payload plus MAC would be a pre-image
tests/test_derivepassphrase_cli_export_vault.py 404)         # attack on the underlying hash function (SHA-256), i.e. is
tests/test_derivepassphrase_cli_export_vault.py 405)         # computationally infeasible, and the chance of finding one by
tests/test_derivepassphrase_cli_export_vault.py 406)         # such random sampling is astronomically tiny.
tests/test_derivepassphrase_cli_export_vault.py 407)         with pytest.raises(cryptography.exceptions.InvalidSignature):
tests/test_derivepassphrase_cli_export_vault.py 408)             storeroom.decrypt_master_keys_data(
tests/test_derivepassphrase_cli_export_vault.py 409)                 data, {'encryption_key': key, 'signing_key': key}
tests/test_derivepassphrase_cli_export_vault.py 410)             )
tests/test_derivepassphrase_cli_export_vault.py 411)         with pytest.raises(cryptography.exceptions.InvalidSignature):
tests/test_derivepassphrase_cli_export_vault.py 412)             storeroom.decrypt_session_keys(
tests/test_derivepassphrase_cli_export_vault.py 413)                 data,
tests/test_derivepassphrase_cli_export_vault.py 414)                 {
tests/test_derivepassphrase_cli_export_vault.py 415)                     'hashing_key': key,
tests/test_derivepassphrase_cli_export_vault.py 416)                     'encryption_key': key,
tests/test_derivepassphrase_cli_export_vault.py 417)                     'signing_key': key,
tests/test_derivepassphrase_cli_export_vault.py 418)                 },
tests/test_derivepassphrase_cli_export_vault.py 419)             )
tests/test_derivepassphrase_cli_export_vault.py 420) 
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     421) 
tests/test_derivepassphrase_exporter_cli.py     422) class TestVaultNativeConfig:
tests/test_derivepassphrase_exporter_cli.py     423)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     424)         ['iterations', 'result'],
tests/test_derivepassphrase_exporter_cli.py     425)         [
tests/test_derivepassphrase_exporter_cli.py     426)             (100, b'6ede361e81e9c061efcdd68aeb768b80'),
tests/test_derivepassphrase_exporter_cli.py     427)             (200, b'bcc7d01e075b9ffb69e702bf701187c1'),
tests/test_derivepassphrase_exporter_cli.py     428)         ],
tests/test_derivepassphrase_exporter_cli.py     429)     )
tests/test_derivepassphrase_exporter_cli.py     430)     def test_200_pbkdf2_manually(self, iterations: int, result: bytes) -> None:
Marco Ricci Fix formatting and linting...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     433)                 tests.VAULT_MASTER_KEY.encode('utf-8'), 32, iterations
tests/test_derivepassphrase_exporter_cli.py     434)             )
tests/test_derivepassphrase_exporter_cli.py     435)             == result
tests/test_derivepassphrase_exporter_cli.py     436)         )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     438)     def test_201_export_vault_native_data_no_arguments(
tests/test_derivepassphrase_exporter_cli.py     439)         self, monkeypatch: pytest.MonkeyPatch
tests/test_derivepassphrase_exporter_cli.py     440)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     441)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     442)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     443)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     444)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     445)             vault_config=tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     446)             vault_key=tests.VAULT_MASTER_KEY,
tests/test_derivepassphrase_exporter_cli.py     447)         ):
tests/test_derivepassphrase_exporter_cli.py     448)             parsed_config = vault_native.export_vault_native_data(None)
tests/test_derivepassphrase_exporter_cli.py     449)         assert parsed_config == tests.VAULT_V03_CONFIG_DATA
tests/test_derivepassphrase_exporter_cli.py     450) 
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     451)     @pytest.mark.parametrize(
tests/test_derivepassphrase_exporter_cli.py     452)         ['parser_class', 'config', 'result'],
tests/test_derivepassphrase_exporter_cli.py     453)         [
tests/test_derivepassphrase_exporter_cli.py     454)             pytest.param(
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     456)                 tests.VAULT_V02_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     457)                 tests.VAULT_V02_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py     458)                 id='0.2',
tests/test_derivepassphrase_exporter_cli.py     459)             ),
tests/test_derivepassphrase_exporter_cli.py     460)             pytest.param(
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     462)                 tests.VAULT_V03_CONFIG,
tests/test_derivepassphrase_exporter_cli.py     463)                 tests.VAULT_V03_CONFIG_DATA,
tests/test_derivepassphrase_exporter_cli.py     464)                 id='0.3',
tests/test_derivepassphrase_exporter_cli.py     465)             ),
tests/test_derivepassphrase_exporter_cli.py     466)         ],
tests/test_derivepassphrase_exporter_cli.py     467)     )
tests/test_derivepassphrase_exporter_cli.py     468)     def test_300_result_caching(
tests/test_derivepassphrase_exporter_cli.py     469)         self,
tests/test_derivepassphrase_exporter_cli.py     470)         monkeypatch: pytest.MonkeyPatch,
Marco Ricci Rename `vault_v03_and_below...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     472)         config: str,
tests/test_derivepassphrase_exporter_cli.py     473)         result: dict[str, Any],
tests/test_derivepassphrase_exporter_cli.py     474)     ) -> None:
tests/test_derivepassphrase_exporter_cli.py     475)         def null_func(name: str) -> Callable[..., None]:
tests/test_derivepassphrase_exporter_cli.py     476)             def func(*_args: Any, **_kwargs: Any) -> None:  # pragma: no cover
tests/test_derivepassphrase_exporter_cli.py     477)                 msg = f'disallowed and stubbed out function {name} called'
tests/test_derivepassphrase_exporter_cli.py     478)                 raise AssertionError(msg)
Marco Ricci Fix formatting and linting...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     480)             return func
tests/test_derivepassphrase_exporter_cli.py     481) 
tests/test_derivepassphrase_exporter_cli.py     482)         runner = click.testing.CliRunner(mix_stderr=False)
tests/test_derivepassphrase_exporter_cli.py     483)         with tests.isolated_vault_exporter_config(
tests/test_derivepassphrase_exporter_cli.py     484)             monkeypatch=monkeypatch,
tests/test_derivepassphrase_exporter_cli.py     485)             runner=runner,
tests/test_derivepassphrase_exporter_cli.py     486)             vault_config=config,
tests/test_derivepassphrase_exporter_cli.py     487)         ):
Marco Ricci Fix formatting and linting...

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     488)             parser = parser_class(
tests/test_derivepassphrase_exporter_cli.py     489)                 base64.b64decode(config), tests.VAULT_MASTER_KEY
tests/test_derivepassphrase_exporter_cli.py     490)             )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

tests/test_derivepassphrase_exporter_cli.py     493)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     494)                 parser, '_parse_contents', null_func('_parse_contents')
tests/test_derivepassphrase_exporter_cli.py     495)             )
tests/test_derivepassphrase_exporter_cli.py     496)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     497)                 parser, '_derive_keys', null_func('_derive_keys')
tests/test_derivepassphrase_exporter_cli.py     498)             )
tests/test_derivepassphrase_exporter_cli.py     499)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     500)                 parser, '_check_signature', null_func('_check_signature')
tests/test_derivepassphrase_exporter_cli.py     501)             )
tests/test_derivepassphrase_exporter_cli.py     502)             monkeypatch.setattr(
tests/test_derivepassphrase_exporter_cli.py     503)                 parser, '_decrypt_payload', null_func('_decrypt_payload')
tests/test_derivepassphrase_exporter_cli.py     504)             )
Marco Ricci Rename vault v0.2/v0.3 clas...

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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

Marco Ricci authored 4 months ago

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