def test_override_set_credentials(self): base_url = 'https://goji.example.com/' runner = CliRunner() with runner.isolated_filesystem(): os.environ['HOME'] = './' with open('.netrc', 'w') as rcfile: rcfile.write(dedent("""\ machine goji3.example.com login df password mypassword machine goji.example.com login delisa password foobar+1 machine goji2.example.com login delisa password foober_1-""")) os.chmod('.netrc', S_IWUSR | S_IRUSR) set_credentials(base_url, 'kylef', '39481-a') with open('.netrc', 'r') as rcfile: self.assertEqual(dedent("""\ machine goji3.example.com login df password mypassword machine goji2.example.com login delisa password foober_1- machine goji.example.com login kylef password 39481-a"""), rcfile.read())
def test_override_set_credentials(self): base_url = 'https://goji.example.com/' runner = CliRunner() with runner.isolated_filesystem(): os.environ['HOME'] = './' with open('.netrc', 'w') as rcfile: rcfile.write( dedent("""\ machine goji3.example.com login df password mypassword machine goji.example.com login delisa password foobar+1 machine goji2.example.com login delisa password foober_1-""")) os.chmod('.netrc', S_IWUSR | S_IRUSR) set_credentials(base_url, 'kylef', '39481-a') with open('.netrc', 'r') as rcfile: self.assertEqual( dedent("""\ machine goji3.example.com login df password mypassword machine goji2.example.com login delisa password foober_1- machine goji.example.com login kylef password 39481-a"""), rcfile.read())
def test_create_file_set_credentials(self): base_url = 'https://goji.example.com/' runner = CliRunner() with runner.isolated_filesystem(): os.environ['HOME'] = './' set_credentials(base_url, 'kylef', '39481-a') with open('.netrc', 'r') as rcfile: self.assertEqual(dedent("""\ machine goji.example.com login kylef password 39481-a"""), rcfile.read())
def test_create_file_set_credentials(self): base_url = 'https://goji.example.com/' runner = CliRunner() with runner.isolated_filesystem(): os.environ['HOME'] = './' set_credentials(base_url, 'kylef', '39481-a') with open('.netrc', 'r') as rcfile: self.assertEqual( dedent("""\ machine goji.example.com login kylef password 39481-a"""), rcfile.read())
def login(base_url): """Authenticate with JIRA server""" email, password = get_credentials(base_url) if email is not None: if not click.confirm('This server is already configured. Override?'): return click.echo('Enter your JIRA credentials') email = click.prompt('Email', type=str) password = click.prompt('Password', type=str, hide_input=True) set_credentials(base_url, email, password)
def login(base_url): """Authenticate with JIRA server""" email, password = get_credentials(base_url) if email is not None: if not click.confirm('This server is already configured. Override?'): return click.echo('Enter your JIRA credentials') email = click.prompt('Email', type=str) password = click.prompt('Password', type=str, hide_input=True) client = JIRAClient(base_url, auth=(email, password)) check_login(client) set_credentials(base_url, email, password)