diff --git a/tests/conftest.py b/tests/conftest.py index 1b4c9211d11b1a5590b7c568e7c8191c1c827da8..b848ea7ff7a713000f6e90843715c327b5d19e3d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -161,3 +161,29 @@ def sample_project_directory(tmpdir): gimmecert.commands.client(io.StringIO(), io.StringIO(), tmpdir.strpath, entity_name, custom_csr_path) return tmpdir + + +@pytest.fixture +def gctmpdir(tmpdir): + """ + Fixture that initialises Gimmecert project within tmpdir with a + simple CA hierarchy. + + Initialised CA hierarchy is 1 level deep, with basename used being + identical to temporary directory base name. + + The fixture is useful in testing of commands where the CA + hierarchy does not matter (almost anything except init/status + commands). + + :param tmpdir: Temporary directory (normally pytest tmpdir fixture) created for running the test. + :type tmpdir: py.path.local + + :returs: Parent directory where Gimmecert has been initialised. Essentially the tmpdir fixture. + :rtype: py.path.local + """ + + # Initialise one-level deep hierarchy. + gimmecert.commands.init(io.StringIO(), io.StringIO(), tmpdir.strpath, tmpdir.basename, 1) + + return tmpdir