コード例 #1
0
ファイル: test_auth.py プロジェクト: kylef/goji
 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())
コード例 #2
0
 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())
コード例 #3
0
ファイル: test_auth.py プロジェクト: kylef/goji
 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())
コード例 #4
0
 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())
コード例 #5
0
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)
コード例 #6
0
ファイル: commands.py プロジェクト: kylef/goji
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)