def test_artifactory_config(self):
        cfg = ("[foo.net/artifactory]\n" + "username=admin\n" +
               "password=ilikerandompasswords\n" + "verify=False\n" +
               "cert=~/path-to-cert\n" + "[http://bar.net/artifactory]\n" +
               "username=foo\n" + "password=bar\n")

        tf = tempfile.NamedTemporaryFile(mode="w+", delete=False)
        try:
            tf.write(cfg)
            tf.flush()
            tf.close()
            cfg = artifactory.read_config(tf.name)
        finally:
            os.remove(tf.name)

        c = artifactory.get_config_entry(cfg, "foo.net/artifactory")
        self.assertEqual(c["username"], "admin")
        self.assertEqual(c["password"], "ilikerandompasswords")
        self.assertEqual(c["verify"], False)
        self.assertEqual(c["cert"], os.path.expanduser("~/path-to-cert"))

        c = artifactory.get_config_entry(cfg, "http://bar.net/artifactory")
        self.assertEqual(c["username"], "foo")
        self.assertEqual(c["password"], "bar")
        self.assertEqual(c["verify"], True)

        c = artifactory.get_config_entry(cfg, "bar.net/artifactory")
        self.assertEqual(c["username"], "foo")
        self.assertEqual(c["password"], "bar")

        c = artifactory.get_config_entry(cfg, "https://bar.net/artifactory")
        self.assertEqual(c["username"], "foo")
        self.assertEqual(c["password"], "bar")
示例#2
0
    def test_artifactory_config(self):
        cfg = "[foo.net/artifactory]\n" + \
              "username=admin\n" + \
              "password=ilikerandompasswords\n" + \
              "verify=False\n" + \
              "cert=~/path-to-cert\n" + \
              "[http://bar.net/artifactory]\n" + \
              "username=foo\n" + \
              "password=bar\n"

        with tempfile.NamedTemporaryFile(mode='w+') as tf:
            tf.write(cfg)
            tf.flush()
            cfg = artifactory.read_config(tf.name)

            c = artifactory.get_config_entry(cfg, 'foo.net/artifactory')
            self.assertEqual(c['username'], 'admin')
            self.assertEqual(c['password'], 'ilikerandompasswords')
            self.assertEqual(c['verify'], False)
            self.assertEqual(c['cert'],
                              os.path.expanduser('~/path-to-cert'))

            c = artifactory.get_config_entry(cfg, 'http://bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')
            self.assertEqual(c['verify'], True)

            c = artifactory.get_config_entry(cfg, 'bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')

            c = artifactory.get_config_entry(cfg, 'https://bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')
示例#3
0
    def test_artifactory_config(self):
        cfg = "[foo.net/artifactory]\n" + \
              "username=admin\n" + \
              "password=ilikerandompasswords\n" + \
              "verify=False\n" + \
              "cert=~/path-to-cert\n" + \
              "[http://bar.net/artifactory]\n" + \
              "username=foo\n" + \
              "password=bar\n"

        with tempfile.NamedTemporaryFile(mode='w+') as tf:
            tf.write(cfg)
            tf.flush()
            cfg = artifactory.read_config(tf.name)

            c = artifactory.get_config_entry(cfg, 'foo.net/artifactory')
            self.assertEqual(c['username'], 'admin')
            self.assertEqual(c['password'], 'ilikerandompasswords')
            self.assertEqual(c['verify'], False)
            self.assertEqual(c['cert'], os.path.expanduser('~/path-to-cert'))

            c = artifactory.get_config_entry(cfg, 'http://bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')
            self.assertEqual(c['verify'], True)

            c = artifactory.get_config_entry(cfg, 'bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')

            c = artifactory.get_config_entry(cfg,
                                             'https://bar.net/artifactory')
            self.assertEqual(c['username'], 'foo')
            self.assertEqual(c['password'], 'bar')