def test_url_user_with_user_password_param(self): output = OutputMock() scm = SCMBase(username="******", password="******", output=output) self.assertEqual('https://*****:*****@github.com/conan-io/conan.git', scm.get_url_with_credentials("https://[email protected]/conan-io/conan.git")) self.assertEqual(1, len(output.out)) self.assertIn("WARN: SCM username got from URL, ignoring 'username' parameter", output.out)
def test_scp_url_username_password(self): output = OutputMock() scm = SCMBase(password="******", output=output) self.assertEqual('git:[email protected]:conan-io/conan.git', scm.get_url_with_credentials("git:[email protected]:conan-io/conan.git")) self.assertIn("WARN: URL type not supported, ignoring 'username' and 'password' " "parameters", output.out)
def test_ssh_url_with_username_only_password(self): output = OutputMock() scm = SCMBase(password="******", output=output) self.assertEqual('ssh://[email protected]/conan-io/conan.git', scm.get_url_with_credentials("ssh://[email protected]/conan-io/conan.git")) self.assertEqual(1, len(output.out)) self.assertIn("WARN: SCM password cannot be set for ssh url, ignoring parameter", output.out)
def test_url_user_pass_with_password_param(self): output = OutputMock() scm = SCMBase(password="******", output=output) self.assertEqual('http://*****:*****@github.com/conan-io/conan.git', scm.get_url_with_credentials( "http://*****:*****@github.com/conan-io/conan.git")) self.assertEqual(1, len(output.out)) self.assertIn("WARN: SCM password got from URL, ignoring 'password' parameter", output.out)
def test_git_username_password(self): output = OutputMock() scm = SCMBase(password="******", username="******", output=output) self.assertEqual("git://github.com/conan-io/conan.git", scm.get_url_with_credentials("git://github.com/conan-io/conan.git")) self.assertEqual(2, len(output.out)) self.assertIn("WARN: SCM password cannot be set for git url, ignoring parameter", output.out) self.assertIn("WARN: SCM password cannot be set for git url, ignoring parameter", output.out)
def test_ssh_url_with_username_and_username_password(self): output = OutputMock() scm = SCMBase(password="******", username="******", output=output) self.assertEqual('ssh://[email protected]/conan-io/conan.git', scm.get_url_with_credentials("ssh://[email protected]/conan-io/conan.git")) self.assertEqual(2, len(output.out)) self.assertIn("WARN: SCM password cannot be set for ssh url, ignoring parameter", output.out) self.assertIn("WARN: SCM username got from URL, ignoring 'username' parameter", output.out)
def test_scp_only_password(self): output = OutputMock() scm = SCMBase(password="******", output=output) self.assertEqual( "[email protected]:conan-io/conan.git", scm.get_url_with_credentials("[email protected]:conan-io/conan.git")) self.assertIn( "WARN: SCM password cannot be set for scp url, ignoring parameter", output.out)
def test_file_url_with_username_password_params(self): output = OutputMock() scm = SCMBase(username="******", password="******", output=output) self.assertEqual('file://path/to/.git', scm.get_url_with_credentials("file://path/to/.git")) self.assertEqual(2, len(output.out)) self.assertIn("WARN: SCM username cannot be set for file url, ignoring parameter", output.out) self.assertIn("WARN: SCM password cannot be set for file url, ignoring parameter", output.out)
def test_ssh_url_with_username_password_and_only_username(self): output = OutputMock() scm = SCMBase(username="******", output=output) self.assertEqual('ssh://[email protected]/conan-io/conan.git', scm.get_url_with_credentials("ssh://*****:*****@github.com/conan-io/conan.git")) self.assertEqual(2, len(output.out)) self.assertIn("WARN: SCM username got from URL, ignoring 'username' parameter", output.out) self.assertIn("WARN: Password in URL cannot be set for 'ssh' SCM type, removing it", output.out)
def test_scp_only_username(self): output = OutputMock() scm = SCMBase(username="******", output=output) self.assertEqual( '[email protected]:conan-io/conan.git', scm.get_url_with_credentials("[email protected]:conan-io/conan.git")) self.assertIn( "WARN: SCM username got from URL, ignoring 'username' parameter", output.out)
def test_url_with_user_password_param(self): scm = SCMBase(username="******", password="******") self.assertEqual('https://*****:*****@github.com/conan-io/conan.git', scm.get_url_with_credentials("https://github.com/conan-io/conan.git"))
def test_url_password(self): scm = SCMBase() self.assertEqual('http://*****:*****@github.com/conan-io/conan.git', scm.get_url_with_credentials( "http://*****:*****@github.com/conan-io/conan.git"))
def test_url_with_user_password_characters_param(self): scm = SCMBase(username="******", password="******") self.assertEqual('https://el+ni%C3%B1o:la+contra%25se%C3%[email protected]/conan-io/conan.git', scm.get_url_with_credentials("https://github.com/conan-io/conan.git"))
def test_git(self): scm = SCMBase() self.assertEqual('git://github.com/conan-io/conan.git', scm.get_url_with_credentials("git://github.com/conan-io/conan.git"))
def test_file_url(self): scm = SCMBase() self.assertEqual("file://path/to/.git", scm.get_url_with_credentials("file://path/to/.git"))
def test_url_user_with_password_param(self): scm = SCMBase(password="******") self.assertEqual('https://*****:*****@github.com/conan-io/conan.git', scm.get_url_with_credentials("https://[email protected]/conan-io/conan.git"))
def test_ssh_username(self): scm = SCMBase(username="******") self.assertEqual('ssh://[email protected]/conan-io/conan.git', scm.get_url_with_credentials("ssh://github.com/conan-io/conan.git"))