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)
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role.lookup(connection, "admin") self.assertIsNotNone(role) self.assertEqual(role.role_name(), "admin")
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Role.list(connection) self.assertGreater(len(names), 65) self.assertIn("admin", names)
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Server.list(connection) self.assertGreater(len(names), 3) self.assertIn("Default|Manage", names)
def test_create(self): pem = ("-----BEGIN CERTIFICATE-----\n" "MIIC3TCCAkYCCQCJtpKDQbobyTANBgkqhkiG9w0BAQsFADCBsjELMAkGA1UEBhMC\n" "VVMxCzAJBgNVBAgMAlRYMQ8wDQYDVQQHDAZBdXN0aW4xHjAcBgNVBAoMFU1hcmtM\n" "b2dpYyBDb3Jwb3JhdGlvbjEXMBUGA1UECwwOVFggRW5naW5lZXJpbmcxITAfBgNV\n" "BAMMGE1hcmtMb2dpYyBUWCBFbmdpbmVlcmluZzEpMCcGCSqGSIb3DQEJARYabm9y\n" "bWFuLndhbHNoQG1hcmtsb2dpYy5jb20wHhcNMTQwODI3MTkyMzQyWhcNMTUwODI3\n" "MTkyMzQyWjCBsjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAlRYMQ8wDQYDVQQHDAZB\n" "dXN0aW4xHjAcBgNVBAoMFU1hcmtMb2dpYyBDb3Jwb3JhdGlvbjEXMBUGA1UECwwO\n" "VFggRW5naW5lZXJpbmcxITAfBgNVBAMMGE1hcmtMb2dpYyBUWCBFbmdpbmVlcmlu\n" "ZzEpMCcGCSqGSIb3DQEJARYabm9ybWFuLndhbHNoQG1hcmtsb2dpYy5jb20wgZ8w\n" "DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJSo3wFMDvTV7Q+4NDDMu9aJZ6uK4l8b\n" "ACIk5/Ug+MoST+CuIfeBlb2Y6dxNCwkADwVPpykslDcHYFygxFIcnHHVhgqZ0xzu\n" "LPXBagXmHyj+mb6im1tkbqAxQ7gj/SDeCnQYRIwNRlGgWZJFViaYJH3CC8G/f16F\n" "IhDyQS3h28W3AgMBAAEwDQYJKoZIhvcNAQELBQADgYEAWbidV4huPlf8Ac0c3Cbs\n" "Nx2xogODSjNPKqwug0Y3jKx33uxeY7i9oParWSnVFkG0JYUZEfrO5fmtS6JSA1Lk\n" "e3BioC9xgclEYFiDoZSARasL8hdNvu7v+EYZEnS43rR4M7CQiq/Tf50o4VjiVM9S\n" "I0Bo+VZSaShQKipBEHS8sP8=\n" "-----END CERTIFICATE-----\n") connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) cert = Authority.create(connection, pem) self.assertIsNotNone(cert) self.assertEqual('true', cert.enabled()) self.assertIsNotNone(cert.properties()) cert.delete(connection)
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) privileges = Privilege.list(connection) self.assertGreater(len(privileges), 300) self.assertIn("execute|manage-admin", privileges)
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)
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User.lookup(connection, "nobody") self.assertIsNotNone(user) self.assertEqual(user.user_name(), "nobody")
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) privilege = Privilege.lookup(connection, "manage-admin", "execute") self.assertIsNotNone(privilege) self.assertEqual(privilege.privilege_name(), "manage-admin")
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) users = User.list(connection) self.assertGreater(len(users), 2) self.assertIn("nobody", users)
def test_load(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = HttpServer("Manage", "Default") self.assertEqual(server.server_name(), "Manage") self.assertIsNotNone(server.read(connection)) self.assertEqual("http", server.server_type())
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = Server.lookup(connection, "Manage") self.assertIsNotNone(server) self.assertEqual(server.server_name(), "Manage")
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role.lookup(connection, "admin") self.assertIsNotNone(role) self.assertEqual(role.role_name(), "admin")
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Role.list(connection) self.assertGreater(len(names), 65) self.assertIn("admin", names)
def test_lookup_action(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) privilege = Privilege.lookup(connection, kind="execute", \ action="http://marklogic.com/xdmp/privileges/admin-module-write") self.assertIsNotNone(privilege) self.assertEqual(privilege.privilege_name(), "admin-module-write")
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Authority.list(connection) auth = Authority.lookup(connection, names[0]) self.assertIsNotNone(auth) self.assertEqual(auth.certificate_id(), names[0])
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) users = User.list(connection) self.assertGreater(len(users), 2) self.assertIn("nobody", users)
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User.lookup(connection, "nobody") self.assertIsNotNone(user) self.assertEqual(user.user_name(), "nobody")
def test_load(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = HttpServer("Manage", "Default") self.assertEqual(server.server_name(), "Manage") self.assertIsNotNone(server.read(connection)) self.assertEqual("http", server.server_type())
def test_lookup(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = Server.lookup(connection, "Manage") self.assertIsNotNone(server) self.assertEqual(server.server_name(), "Manage")
def _test_ssl_certificate_pems(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = HttpServer("foo-http", "Default", 10101, '/', 'Documents') self.assertEqual(server.server_name(), "foo-http") server.create(connection) self.assertIsNotNone(server) self.assertEqual("http", server.server_type()) pem1 = "-----BEGIN CERTIFICATE-----\n\ MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEc\n\ MBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBT\n\ ZWN1cmUgZUJ1c2luZXNzIENBLTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQw\n\ MDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMTRXF1aWZheCBTZWN1cmUgSW5j\n\ LjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENBLTEwgZ8wDQYJ\n\ KoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ1MRo\n\ RvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBu\n\ WqDZQu4aIZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKw\n\ Env+j6YDAgMBAAGjZjBkMBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHR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OBBYEFL6ooHRyUGtEt8kj2Puo/7NXa2hsMA0GCSqGSIb3DQEBBAUA\n\ A4GBADDiAVGqx+pf2rnQZQ8w1j7aDRRJbpGTJxQx78T3LUX47Me/okENI7SS+RkA\n\ Z70Br83gcfxaz2TE4JaY0KNA4gGK7ycH8WUBikQtBmV1UsCGECAhX2xrD2yuCRyv\n\ 8qIYNMR1pHMc8Y3c7635s3a0kr/clRAevsvIO1qEYBlWlKlV\n\ -----END CERTIFICATE-----" server.add_ssl_client_certificate_pem(pem1) server.update(connection) server.read(connection) self.assertEqual(1, len(server.ssl_client_certificate_pems())) server.set_ssl_client_certificate_pems([pem1,pem2]) server.update(connection) server.read(connection) self.assertEqual(2, len(server.ssl_client_certificate_pems())) server.delete(connection) server = Server.lookup(connection, "foo-http") self.assertIsNone(server)
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Authority.list(connection, include_names=True) self.assertGreater(len(names), 100) found = False for name in names: found = found or "Equifax" in name self.assertEqual(True, found)
def test_create_webdav_server(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = WebDAVServer("foo-webdav", "Default", 10101, '/', 'Documents') self.assertEqual(server.server_name(), "foo-webdav") server.create(connection) self.assertIsNotNone(server) self.assertEqual("webdav", server.server_type()) server.delete(connection) server = Server.lookup(connection, "foo-webdav") self.assertIsNone(server)
def test_create_webdav_server(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) server = WebDAVServer("foo-webdav", "Default", 10101, '/', 'Documents') self.assertEqual(server.server_name(), "foo-webdav") server.create(connection) self.assertIsNotNone(server) self.assertEqual("webdav", server.server_type()) server.delete(connection) server = Server.lookup(connection, "foo-webdav") self.assertIsNone(server)
def test_save_privilege(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) privilege = Privilege("foo-privilege","http://example.com/","execute") privilege.create(connection) privilege.add_role_name("manage-user") privilege.update(connection) self.assertIn("manage-user", privilege.role_names()) privilege.delete(connection)
def test_ssl_certificate_pems(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) cluster = LocalCluster(connection=connection) version = cluster.version() if (version.startswith("4") or version.startswith("5") or version.startswith("6") or version.startswith("7") or version.startswith("8.0-1") or version.startswith("8.0-2") or version.startswith("8.0-3")): pass else: self._test_ssl_certificate_pems()
def test_create_remove_privilege(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) privilege = Privilege("foo-privilege","http://example.com/","execute") privilege.create(connection) the_privilege = Privilege.lookup(connection, "foo-privilege", "execute") self.assertIsNotNone(the_privilege) the_privilege.delete(connection) the_privilege = Privilege.lookup(connection, "foo-privilege", "execute") self.assertIsNone(the_privilege)
def test_create_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) new_user = User("foo-user", "password") self.assertEqual(new_user.user_name(), "foo-user") new_user.create(connection) users = User.list(connection) self.assertIn("foo-user", users) new_user.delete(connection)
def test_create_privilege(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) new_privilege = Privilege("foo-privilege","http://example.com/","execute") self.assertEqual(new_privilege.privilege_name(), "foo-privilege") new_privilege.create(connection) privileges = Privilege.list(connection) self.assertIn("execute|foo-privilege", privileges) new_privilege.delete(connection)
def test_create_remove_role(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role("foo-role") role.create(connection) the_role = Role.lookup(connection, "foo-role") self.assertIsNotNone(the_role) the_role.delete(connection) the_role = Role.lookup(connection, "foo-role") self.assertIsNone(the_role)
def test_create_remove_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User("foo-user", "password") user.create(connection) the_user = User.lookup(connection, "foo-user") self.assertIsNotNone(the_user) the_user.delete(connection) the_user = User.lookup(connection, "foo-user") self.assertIsNone(the_user)
def test_create_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) new_user = User("foo-user", "password") self.assertEqual(new_user.user_name(), "foo-user") new_user.create(connection) users = User.list(connection) self.assertIn("foo-user", users) new_user.delete(connection)
def test_save_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User("foo-user", "password") self.assertIsNone(user.create(connection).description()) user.set_description("This is the foo user") user.update(connection) user = User.lookup(connection, "foo-user") self.assertEqual("This is the foo user", user.description()) user.delete(connection)
def test_save_role(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role("foo-role") self.assertIsNone(role.create(connection).description()) role.set_description("This is the foo role") role.update(connection) role = Role.lookup(connection, "foo-role") self.assertEqual("This is the foo role", role.description()) role.delete(connection)
def test_create_remove_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User("foo-user", "password") user.create(connection) the_user = User.lookup(connection, "foo-user") self.assertIsNotNone(the_user) the_user.delete(connection) the_user = User.lookup(connection, "foo-user") self.assertIsNone(the_user)
def test_create_remove_role(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role("foo-role") role.create(connection) the_role = Role.lookup(connection, "foo-role") self.assertIsNotNone(the_role) the_role.delete(connection) the_role = Role.lookup(connection, "foo-role") self.assertIsNone(the_role)
def test_save_user(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) user = User("foo-user", "password") self.assertIsNone(user.create(connection).description()) user.set_description("This is the foo user") user.update(connection) user = User.lookup(connection, "foo-user") self.assertEqual("This is the foo user", user.description()) user.delete(connection)
def test_save_role(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) role = Role("foo-role") self.assertIsNone(role.create(connection).description()) role.set_description("This is the foo role") role.update(connection) role = Role.lookup(connection, "foo-role") self.assertEqual("This is the foo role", role.description()) role.delete(connection)
def test_list(self): connection = Connection.make_connection(tc.hostname, tc.admin, tc.password) names = Server.list(connection) self.assertGreater(len(names), 3) self.assertIn("Default|Manage", names)