def test_check_secrets(self): wf_data = { "steps": [{ "uses": "docker://alpine:3.9", "args": ["ls", "-ltr"], "secrets": ["SECRET_ONE", "SECRET_TWO"], }] } wf = WorkflowParser.parse(wf_data=wf_data) # in dry-run, secrets are ignored runner = WorkflowRunner(ConfigLoader.load(dry_run=True)) runner._process_secrets(wf) # now go back to not dry-running runner = WorkflowRunner(ConfigLoader.load()) # when CI=true it should fail os.environ["CI"] = "true" self.assertRaises(SystemExit, runner._process_secrets, wf) # add one secret os.environ["SECRET_ONE"] = "1234" # it should fail again, as we're missing one self.assertRaises(SystemExit, runner._process_secrets, wf) os.environ.pop("CI") # now is fine with patch("getpass.getpass", return_value="5678"): runner._process_secrets(wf) # pop the other os.environ.pop("SECRET_ONE")
def test_check_secrets(self): wf = YMLWorkflow(""" version: '1' steps: - uses: docker://alpine:3.9 args: ["ls -ltr"] secrets: ["SECRET_ONE", "SECRET_TWO"] """) wf.parse() # in dry-run, secrets are ignored runner = WorkflowRunner(PopperConfig(dry_run=True)) runner._process_secrets(wf) # now go back to not dry-running runner = WorkflowRunner(PopperConfig()) # when CI=true it should fail os.environ['CI'] = 'true' self.assertRaises(SystemExit, runner._process_secrets, wf) # add one secret os.environ['SECRET_ONE'] = '1234' # it should fail again, as we're missing one self.assertRaises(SystemExit, runner._process_secrets, wf) os.environ.pop('CI') # now is fine with patch('getpass.getpass', return_value='5678'): runner._process_secrets(wf) # pop the other os.environ.pop('SECRET_ONE')