mirror of
https://github.com/NixOS/nix.git
synced 2025-12-01 14:41:00 +01:00
fix: ensure access-token matches are complete
This commit is contained in:
parent
a9f4d73d3e
commit
269efa01b3
2 changed files with 31 additions and 4 deletions
|
|
@ -20,16 +20,36 @@ public:
|
|||
void TearDown() override { }
|
||||
};
|
||||
|
||||
TEST_F(AccessKeysTest, singleGitHub)
|
||||
TEST_F(AccessKeysTest, singleOrgGitHub)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
fetchSettings.accessTokens.get().insert({"github.com","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");
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, nonMatches)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, noPartialMatches)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(AccessKeysTest, repoGitHub)
|
||||
{
|
||||
fetchers::Settings fetchSettings = fetchers::Settings{};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue