Exemplo n.º 1
0
    def test_creds_secret_can_be_overwritten_repo_info(self, monkeypatch):
        task = GetRepoInfo(token_secret="MY_SECRET")

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(MY_SECRET={"key": 42})):
                task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
Exemplo n.º 2
0
    def test_creds_are_pulled_from_secret_at_runtime_repo_info(
            self, monkeypatch):
        task = GetRepoInfo(token_secret="GITHUB_ACCESS_TOKEN")

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with prefect.context(secrets=dict(GITHUB_ACCESS_TOKEN={"key": 42})):
            task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
Exemplo n.º 3
0
    def test_creds_are_pulled_from_secret_at_runtime(self, monkeypatch):
        task = GetRepoInfo()

        req = MagicMock()
        monkeypatch.setattr("prefect.tasks.github.repos.requests", req)

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(
                    GITHUB_ACCESS_TOKEN={"key": 42})):
                task.run(repo="org/repo")

        assert req.get.call_args[1]["headers"][
            "AUTHORIZATION"] == "token {'key': 42}"
Exemplo n.º 4
0
 def test_repo_is_required_eventually(self):
     task = GetRepoInfo()
     with pytest.raises(ValueError) as exc:
         task.run()
     assert "repo" in str(exc.value)
Exemplo n.º 5
0
 def test_repo_is_required_eventually(self):
     task = GetRepoInfo()
     with pytest.raises(ValueError, match="repo"):
         task.run()