Marco Ricci commited on 2025-02-04 09:53:14
Zeige 1 geänderte Dateien mit 46 Einfügungen und 0 Löschungen.
Like vault(1), `derivepassphrase vault` should print the service's notes to standard error when deriving a passphrase. But due to an oversight, it currently doesn't. Explicitly test for this.
| ... | ... |
@@ -1872,6 +1872,52 @@ class TestCLI: |
| 1872 | 1872 |
map(is_harmless_config_import_warning, caplog.record_tuples) |
| 1873 | 1873 |
), 'unexpected error output' |
| 1874 | 1874 |
|
| 1875 |
+ @pytest.mark.xfail( # pragma: no cover |
|
| 1876 |
+ reason='not implemented yet', |
|
| 1877 |
+ raises=AssertionError, |
|
| 1878 |
+ strict=True, |
|
| 1879 |
+ ) |
|
| 1880 |
+ def test_207_service_with_notes_actually_prints_notes( |
|
| 1881 |
+ self, |
|
| 1882 |
+ ) -> None: |
|
| 1883 |
+ """Service notes are printed, if they exist.""" |
|
| 1884 |
+ runner = click.testing.CliRunner(mix_stderr=False) |
|
| 1885 |
+ # TODO(the-13th-letter): Rewrite using parenthesized |
|
| 1886 |
+ # with-statements. |
|
| 1887 |
+ # https://the13thletter.info/derivepassphrase/latest/pycompatibility/#after-eol-py3.9 |
|
| 1888 |
+ with contextlib.ExitStack() as stack: |
|
| 1889 |
+ monkeypatch = stack.enter_context(pytest.MonkeyPatch.context()) |
|
| 1890 |
+ stack.enter_context( |
|
| 1891 |
+ tests.isolated_vault_config( |
|
| 1892 |
+ monkeypatch=monkeypatch, |
|
| 1893 |
+ runner=runner, |
|
| 1894 |
+ vault_config={
|
|
| 1895 |
+ 'global': {
|
|
| 1896 |
+ 'phrase': DUMMY_PASSPHRASE, |
|
| 1897 |
+ }, |
|
| 1898 |
+ 'services': {
|
|
| 1899 |
+ DUMMY_SERVICE: {
|
|
| 1900 |
+ 'notes': 'Some notes here', |
|
| 1901 |
+ **DUMMY_CONFIG_SETTINGS, |
|
| 1902 |
+ }, |
|
| 1903 |
+ }, |
|
| 1904 |
+ }, |
|
| 1905 |
+ ) |
|
| 1906 |
+ ) |
|
| 1907 |
+ result_ = runner.invoke( |
|
| 1908 |
+ cli.derivepassphrase_vault, |
|
| 1909 |
+ ['--', DUMMY_SERVICE], |
|
| 1910 |
+ ) |
|
| 1911 |
+ result = tests.ReadableResult.parse(result_) |
|
| 1912 |
+ assert result.clean_exit(), 'expected clean exit' |
|
| 1913 |
+ assert result.output, 'expected program output' |
|
| 1914 |
+ assert result.output.strip() == DUMMY_RESULT_PASSPHRASE.decode('ascii'), 'expected known program output'
|
|
| 1915 |
+ assert result.stderr, 'expected stderr' |
|
| 1916 |
+ assert 'Error:' not in result.stderr, ( |
|
| 1917 |
+ 'expected no error messages on stderr' |
|
| 1918 |
+ ) |
|
| 1919 |
+ assert result.stderr.strip() == 'Some notes here', 'expected known stderr contents' |
|
| 1920 |
+ |
|
| 1875 | 1921 |
@Parametrize.VAULT_CHARSET_OPTION |
| 1876 | 1922 |
def test_210_invalid_argument_range( |
| 1877 | 1923 |
self, |
| 1878 | 1924 |