Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
https-store.hh
Go to the documentation of this file.
1#pragma once
3
4#include <gtest/gtest.h>
5#include <gmock/gmock.h>
6
10#include "nix/store/globals.hh"
13#include "nix/util/os-string.hh"
14#include "nix/util/processes.hh"
15
16namespace nix::testing {
17
19
24class TestHttpBinaryCacheStore : public HttpBinaryCacheStore
25{
26public:
27 TestHttpBinaryCacheStore(const TestHttpBinaryCacheStore &) = delete;
28 TestHttpBinaryCacheStore(TestHttpBinaryCacheStore &&) = delete;
29 TestHttpBinaryCacheStore & operator=(const TestHttpBinaryCacheStore &) = delete;
30 TestHttpBinaryCacheStore & operator=(TestHttpBinaryCacheStore &&) = delete;
31
32 TestHttpBinaryCacheStore(ref<HttpBinaryCacheStoreConfig> config, ref<FileTransfer> fileTransfer)
33 : Store{*config}
34 , BinaryCacheStore{*config}
35 , HttpBinaryCacheStore(config, fileTransfer)
36 {
37 diskCache = nullptr; /* Disable caching, we'll be creating a new binary cache for each test. */
38 }
39
40 void init() override;
41};
42
43class TestHttpBinaryCacheStoreConfig : public HttpBinaryCacheStoreConfig
44{
45public:
46 TestHttpBinaryCacheStoreConfig(ParsedURL url, const Store::Config::Params & params)
47 : StoreConfig(params, FilePathType::Unix)
48 , HttpBinaryCacheStoreConfig(url, params)
49 {
50 }
51
52 ref<TestHttpBinaryCacheStore> openTestStore(ref<FileTransfer> fileTransfer) const;
53};
54
56{
57 std::unique_ptr<AutoDelete> delTmpDir;
58
59public:
60 static void SetUpTestSuite()
61 {
62 initLibStore(/*loadConfig=*/false);
63 }
64
65protected:
66 std::filesystem::path tmpDir, cacheDir;
67 std::filesystem::path caCert, caKey, serverCert, serverKey;
68 std::filesystem::path clientCert, clientKey;
69 Pid serverPid;
70 uint16_t port = 8443;
71 std::shared_ptr<Store> localCacheStore;
72
77 std::unique_ptr<FileTransferSettings> testFileTransferSettings;
78
83 std::shared_ptr<FileTransfer> testFileTransfer;
84
85 static void openssl(Strings args);
86 void SetUp() override;
87 void TearDown() override;
88
89 virtual OsStrings serverArgs();
92};
93
95{
96protected:
97 OsStrings serverArgs() override;
98};
99
100} // namespace nix::testing
Definition processes.hh:39
Definition ref.hh:58
Definition https-store.hh:56
std::unique_ptr< FileTransferSettings > testFileTransferSettings
Definition https-store.hh:77
std::shared_ptr< FileTransfer > testFileTransfer
Definition https-store.hh:83
Definition libstore-network.hh:22
void init() override
Definition https-store.cc:8
Utilities for working with the file system and file paths.
std::list< OsString > OsStrings
Definition os-string.hh:51
Definition url.hh:22
@ Unix
Definition store-api.hh:131