示例#1
0
 def test_false_on_unknown_string(self, m_read_dmi_data):
     """Should return false on an unrelated string."""
     m_read_dmi_data.return_value = "cubs win"
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(False, ret)
示例#2
0
 def setUp(self):
     super(TestAliYunDatasource, self).setUp()
     cfg = {'datasource': {'AliYun': {'timeout': '1', 'max_wait': '1'}}}
     distro = {}
     paths = helpers.Paths({'run_dir': self.tmp_dir()})
     self.ds = ay.DataSourceAliYun(cfg, distro, paths)
     self.metadata_address = self.ds.metadata_urls[0]
示例#3
0
 def test_true_on_aliyun_product(self, m_read_dmi_data):
     """Should return true if the dmi product data has expected value."""
     m_read_dmi_data.return_value = self.ALIYUN_PRODUCT
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(True, ret)
示例#4
0
 def test_false_on_empty_string(self, m_read_dmi_data):
     """Should return false on empty value returned."""
     m_read_dmi_data.return_value = ""
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(False, ret)
示例#5
0
 def test_false_on_unknown_string(self, m_read_dmi_data):
     """Should return false on an unrelated string."""
     m_read_dmi_data.return_value = "cubs win"
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(False, ret)
示例#6
0
 def test_false_on_empty_string(self, m_read_dmi_data):
     """Should return false on empty value returned."""
     m_read_dmi_data.return_value = ""
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(False, ret)
示例#7
0
 def test_true_on_aliyun_product(self, m_read_dmi_data):
     """Should return true if the dmi product data has expected value."""
     m_read_dmi_data.return_value = self.ALIYUN_PRODUCT
     ret = ay._is_aliyun()
     self.assertEqual(self.read_dmi_data_expected,
                      m_read_dmi_data.call_args_list)
     self.assertEqual(True, ret)
 def setUp(self):
     super(TestAliYunDatasource, self).setUp()
     cfg = {"datasource": {"AliYun": {"timeout": "1", "max_wait": "1"}}}
     distro = {}
     paths = helpers.Paths({"run_dir": self.tmp_dir()})
     self.ds = ay.DataSourceAliYun(cfg, distro, paths)
     self.metadata_address = self.ds.metadata_urls[0]
示例#9
0
    def test_parse_public_keys(self):
        public_keys = {}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {'key-pair-0': 'ssh-key-0'}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         [public_keys['key-pair-0']])

        public_keys = {'key-pair-0': 'ssh-key-0', 'key-pair-1': 'ssh-key-1'}
        self.assertEqual(
            set(ay.parse_public_keys(public_keys)),
            set([public_keys['key-pair-0'], public_keys['key-pair-1']]))

        public_keys = {'key-pair-0': ['ssh-key-0', 'ssh-key-1']}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         public_keys['key-pair-0'])

        public_keys = {'key-pair-0': {'openssh-key': []}}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {'key-pair-0': {'openssh-key': 'ssh-key-0'}}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         [public_keys['key-pair-0']['openssh-key']])

        public_keys = {
            'key-pair-0': {
                'openssh-key': ['ssh-key-0', 'ssh-key-1']
            }
        }
        self.assertEqual(ay.parse_public_keys(public_keys),
                         public_keys['key-pair-0']['openssh-key'])
示例#10
0
    def test_parse_public_keys(self):
        public_keys = {}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {'key-pair-0': 'ssh-key-0'}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         [public_keys['key-pair-0']])

        public_keys = {'key-pair-0': 'ssh-key-0', 'key-pair-1': 'ssh-key-1'}
        self.assertEqual(set(ay.parse_public_keys(public_keys)),
                         set([public_keys['key-pair-0'],
                             public_keys['key-pair-1']]))

        public_keys = {'key-pair-0': ['ssh-key-0', 'ssh-key-1']}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         public_keys['key-pair-0'])

        public_keys = {'key-pair-0': {'openssh-key': []}}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {'key-pair-0': {'openssh-key': 'ssh-key-0'}}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         [public_keys['key-pair-0']['openssh-key']])

        public_keys = {'key-pair-0': {'openssh-key': ['ssh-key-0',
                                                      'ssh-key-1']}}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         public_keys['key-pair-0']['openssh-key'])
    def test_parse_public_keys(self):
        public_keys = {}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {"key-pair-0": "ssh-key-0"}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         [public_keys["key-pair-0"]])

        public_keys = {"key-pair-0": "ssh-key-0", "key-pair-1": "ssh-key-1"}
        self.assertEqual(
            set(ay.parse_public_keys(public_keys)),
            set([public_keys["key-pair-0"], public_keys["key-pair-1"]]),
        )

        public_keys = {"key-pair-0": ["ssh-key-0", "ssh-key-1"]}
        self.assertEqual(ay.parse_public_keys(public_keys),
                         public_keys["key-pair-0"])

        public_keys = {"key-pair-0": {"openssh-key": []}}
        self.assertEqual(ay.parse_public_keys(public_keys), [])

        public_keys = {"key-pair-0": {"openssh-key": "ssh-key-0"}}
        self.assertEqual(
            ay.parse_public_keys(public_keys),
            [public_keys["key-pair-0"]["openssh-key"]],
        )

        public_keys = {
            "key-pair-0": {
                "openssh-key": ["ssh-key-0", "ssh-key-1"]
            }
        }
        self.assertEqual(
            ay.parse_public_keys(public_keys),
            public_keys["key-pair-0"]["openssh-key"],
        )