mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
fix: linting
This commit is contained in:
parent
753f00c351
commit
3b5514e0c6
1 changed files with 24 additions and 23 deletions
|
@ -14,86 +14,87 @@ class AccessKeysTest : public ::testing::Test
|
|||
protected:
|
||||
|
||||
public:
|
||||
void SetUp() override {
|
||||
experimentalFeatureSettings.experimentalFeatures.get().insert(Xp::Flakes);
|
||||
void SetUp() override
|
||||
{
|
||||
experimentalFeatureSettings.experimentalFeatures.get().insert(Xp::Flakes);
|
||||
}
|
||||
void TearDown() override { }
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST_F(AccessKeysTest, singleOrgGitHub)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a","token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a", "token"});
|
||||
auto i = Input::fromURL(fetchSettings, "github:a/b");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b");
|
||||
ASSERT_EQ(token,"token");
|
||||
ASSERT_EQ(token, "token");
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, nonMatches)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"github.com","token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com", "token"});
|
||||
auto i = Input::fromURL(fetchSettings, "gitlab:github.com/evil");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/github.com/evil");
|
||||
ASSERT_EQ(token,std::nullopt);
|
||||
ASSERT_EQ(token, std::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, noPartialMatches)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"github.com/partial","token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/partial", "token"});
|
||||
auto i = Input::fromURL(fetchSettings, "github:partial-match/repo");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/partial-match");
|
||||
ASSERT_EQ(token,std::nullopt);
|
||||
ASSERT_EQ(token, std::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, repoGitHub)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"github.com","token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a/b","another_token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a/c","yet_another_token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com", "token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a/b", "another_token"});
|
||||
fetchSettings.accessTokens.get().insert({"github.com/a/c", "yet_another_token"});
|
||||
auto i = Input::fromURL(fetchSettings, "github:a/a");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/a");
|
||||
ASSERT_EQ(token,"token");
|
||||
ASSERT_EQ(token, "token");
|
||||
|
||||
token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b");
|
||||
ASSERT_EQ(token,"another_token");
|
||||
ASSERT_EQ(token, "another_token");
|
||||
|
||||
token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/c");
|
||||
ASSERT_EQ(token,"yet_another_token");
|
||||
ASSERT_EQ(token, "yet_another_token");
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, multipleGitLab)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"gitlab.com","token"});
|
||||
fetchSettings.accessTokens.get().insert({"gitlab.com/a/b","another_token"});
|
||||
fetchSettings.accessTokens.get().insert({"gitlab.com", "token"});
|
||||
fetchSettings.accessTokens.get().insert({"gitlab.com/a/b", "another_token"});
|
||||
auto i = Input::fromURL(fetchSettings, "gitlab:a/b");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/b");
|
||||
ASSERT_EQ(token,"another_token");
|
||||
ASSERT_EQ(token, "another_token");
|
||||
|
||||
token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/c");
|
||||
ASSERT_EQ(token,"token");
|
||||
ASSERT_EQ(token, "token");
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, multipleSourceHut)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"git.sr.ht","token"});
|
||||
fetchSettings.accessTokens.get().insert({"git.sr.ht/~a/b","another_token"});
|
||||
fetchSettings.accessTokens.get().insert({"git.sr.ht", "token"});
|
||||
fetchSettings.accessTokens.get().insert({"git.sr.ht/~a/b", "another_token"});
|
||||
auto i = Input::fromURL(fetchSettings, "sourcehut:a/b");
|
||||
|
||||
auto token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/b");
|
||||
ASSERT_EQ(token,"another_token");
|
||||
ASSERT_EQ(token, "another_token");
|
||||
|
||||
token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/c");
|
||||
ASSERT_EQ(token,"token");
|
||||
ASSERT_EQ(token, "token");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue