Example #1
0
    def test_request(self):
        req = Request(countryName="US", stateOrProvinceName="TX",
                      localityName="Austin", organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0)

        self.assertEqual("US", req.countryName())
        self.assertEqual("TX", req.stateOrProvinceName())
        self.assertEqual("Austin", req.localityName())
        self.assertEqual("*****@*****.**", req.emailAddress())
        self.assertEqual(0, req.version())
        self.assertIsNone(req.v3ext())

        ext = {
            "nsCertType": {
                "critical": False,
                "value": "SSL Server"
                },
            "subjectKeyIdentifier": {
                "critical": False,
                "value": "B2:2C:0C:F8:5E:A7:44:B7"
                }
            }

        req = Request(countryName="US", stateOrProvinceName="TX",
                      localityName="Austin", organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0, v3ext=ext)

        self.assertEqual("SSL Server", req.v3ext()["nsCertType"]["value"])
Example #2
0
    def test_template(self):
        connection = Connection.make_connection(tc.hostname, tc.admin,
                                                tc.password)

        req = Request(countryName="US",
                      stateOrProvinceName="TX",
                      localityName="Austin",
                      organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0)
        temp = Template("Test Template", "Test description", req)

        self.assertEqual("Test Template", temp.template_name())

        temp.create(connection)

        names = Template.list(connection)

        self.assertGreater(len(names), 0)
        self.assertIn(temp.template_id(), names)

        temp.set_template_name("New Name")
        temp.set_template_description("New Description")
        temp.update(connection)
        self.assertIsNotNone(temp)

        newtemp = Template.lookup(connection, temp.template_id())
        self.assertEqual(temp.template_name(), newtemp.template_name())

        temp.delete(connection)

        self.assertIsNotNone(temp)
Example #3
0
    def test_template(self):
        req = Request(countryName="US",
                      stateOrProvinceName="TX",
                      localityName="Austin",
                      organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0)
        temp = Template("Test Template", "Test description", req)

        assert "Test Template" == temp.template_name()

        temp.create(self.connection)

        names = Template.list(self.connection)

        assert len(names) > 0
        assert temp.template_id() in names

        temp.set_template_name("New Name")
        temp.set_template_description("New Description")
        temp.update(self.connection)
        assert temp is not None

        newtemp = Template.lookup(self.connection, temp.template_id())
        assert temp.template_name() == newtemp.template_name()

        temp.delete(self.connection)

        assert temp is not None
    def unmarshal(cls, config):
        """
        Construct a new Template from a flat structure. This method is
        principally used to construct an object from a Management API
        payload. The configuration passed in is largely assumed to be
        valid.

        :param: config: A hash of properties
        :return: A newly constructed User object with the specified properties.
        """
        result = Template("temp", "temp", Request(organizationName="temp"))
        result._config = config

        if 'req' in result._config:
            result._config['req'] = Request.unmarshal(result._config['req'])

        return result
Example #5
0
    def unmarshal(cls, config):
        """
        Construct a new Template from a flat structure. This method is
        principally used to construct an object from a Management API
        payload. The configuration passed in is largely assumed to be
        valid.

        :param: config: A hash of properties
        :return: A newly constructed User object with the specified properties.
        """
        result = Template("temp","temp", Request(organizationName="temp"))
        result._config = config

        if 'req' in result._config:
            result._config['req'] = Request.unmarshal(result._config['req'])

        return result
    def test_request(self):
        req = Request(countryName="US",
                      stateOrProvinceName="TX",
                      localityName="Austin",
                      organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0)

        assert "US" == req.countryName()
        assert "TX" == req.stateOrProvinceName()
        assert "Austin" == req.localityName()
        assert "*****@*****.**" == req.emailAddress()
        assert 0 == req.version()
        assert req.v3ext() is None

        ext = {
            "nsCertType": {
                "critical": False,
                "value": "SSL Server"
            },
            "subjectKeyIdentifier": {
                "critical": False,
                "value": "B2:2C:0C:F8:5E:A7:44:B7"
            }
        }

        req = Request(countryName="US",
                      stateOrProvinceName="TX",
                      localityName="Austin",
                      organizationName="MarkLogic",
                      emailAddress="*****@*****.**",
                      version=0,
                      v3ext=ext)

        assert "SSL Server" == req.v3ext()["nsCertType"]["value"]