Example #1
0
    def _get_credentials(self, realm, user, app, owner, prop):
        """
        @return: clear or encrypted password for specified realm, user
        """

        endpoint = self._get_endpoint(realm, user, app, owner)
        response, content = rest.splunkd_request(
            endpoint, self._session_key, method="GET")
        if response and response.status in (200, 201) and content:
            password = conf.parse_conf_xml_dom(content)[0]
            return password[prop]
        return None
    def _get_credentials(self, realm, user, app, owner, prop):
        """
        @return: clear or encrypted password for specified realm, user
        """

        endpoint = self._get_endpoint(realm, user, app, owner)
        response, content = rest.splunkd_request(
            endpoint, self._session_key, method="GET")
        if response and response.status in (200, 201) and content:
            password = conf.parse_conf_xml_dom(content)[0]
            return password[prop]
        return None
Example #3
0
    def get_all_passwords(self):
        """
        @return: a list of dict when successful, None when failed.
        the dict at least contains
        {
            "realm": xxx,
            "username": yyy,
            "clear_password": zzz,
        }
        """

        endpoint = "{}/services/storage/passwords".format(self._splunkd_uri)
        response, content = rest.splunkd_request(
            endpoint, self._session_key, method="GET")
        if response and response.status in (200, 201) and content:
            return conf.parse_conf_xml_dom(content)
    def get_all_passwords(self):
        """
        @return: a list of dict when successful, None when failed.
        the dict at least contains
        {
            "realm": xxx,
            "username": yyy,
            "clear_password": zzz,
        }
        """

        endpoint = "{}/services/storage/passwords".format(self._splunkd_uri)
        response, content = rest.splunkd_request(
            endpoint, self._session_key, method="GET")
        if response and response.status in (200, 201) and content:
            return conf.parse_conf_xml_dom(content)
Example #5
0
 def test_parse_conf_xml_dom(self):
     with open(op.join(self.cur_dir, "test_xml_dom.sample")) as f:
         xml_content = f.read()
     stanza_objs = configure.parse_conf_xml_dom(xml_content)
     self.assertIsNotNone(stanza_objs)
     self.assertEquals(len(stanza_objs), 3)
     self.assertEquals(stanza_objs[0]["stanza"], "box_account")
     self.assertEquals(stanza_objs[0]["url"], "https://api.box.com")
     self.assertEquals(stanza_objs[0]["client_id"], "<encrypted>")
     self.assertEquals(stanza_objs[0]["client_secret"], "<encrypted>")
     self.assertEquals(stanza_objs[0]["refresh_token"], "<encrypted>")
     self.assertEquals(stanza_objs[0]["access_token"], "<encrypted>")
     self.assertEquals(stanza_objs[1]["stanza"], "box_default")
     self.assertEquals(stanza_objs[1]["collect_file"], "1")
     self.assertEquals(stanza_objs[1]["collect_folder"], "1")
     self.assertEquals(stanza_objs[1]["collect_task"], "1")
     self.assertEquals(stanza_objs[1]["collect_collaboration"], "1")
     self.assertEquals(stanza_objs[1]["collection_interval"], "120")
     self.assertEquals(stanza_objs[2]["stanza"], "box_proxy")
     self.assertEquals(stanza_objs[2]["proxy_enabled"], "1")
     self.assertEquals(stanza_objs[2]["proxy_url"], "10.0.0.10")
     self.assertEquals(stanza_objs[2]["proxy_port"], "9911")
     self.assertEquals(stanza_objs[2]["proxy_username"], "ghost")
     self.assertEquals(stanza_objs[2]["proxy_password"], "hydra")