Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Seelmann <mail@stefan-seelmann.de>2021-01-30 22:44:14 +0300
committerStefan Seelmann <mail@stefan-seelmann.de>2021-01-30 22:51:59 +0300
commit67b96b482bfcce1bb35c2166d97e4c9cb940c195 (patch)
tree3a1acf3b9651b9b870358960c503b9b48dc3a290
parent0c730d2ece7520f284d6b940b58f2b786d42a086 (diff)
DIRSTUDIO-996: Verify default schema is used if no schema is provided
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/OpenLdapTest.java48
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java11
-rw-r--r--tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/OpenLdapConfig.ldif25
3 files changed, 84 insertions, 0 deletions
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/OpenLdapTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/OpenLdapTest.java
index 0eae6d169..519e9b364 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/OpenLdapTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/OpenLdapTest.java
@@ -35,6 +35,7 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
+import org.apache.directory.api.ldap.model.entry.Modification;
import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.ldif.LdifReader;
@@ -44,12 +45,15 @@ import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ModifyMode;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
+import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.NewAttributeWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.SchemaBrowserBot;
import org.apache.directory.studio.test.integration.ui.bots.SearchDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions;
@@ -83,6 +87,8 @@ public class OpenLdapTest
private static final int OPENLDAP_PORT = Integer.parseInt( getOrDefault( "OPENLDAP_PORT", "20389" ) );
private static final String OPENLDAP_ADMIN_DN = getOrDefault( "OPENLDAP_ADMIN_DN", "cn=admin,dc=example,dc=org" );
private static final String OPENLDAP_ADMIN_PASSWORD = getOrDefault( "OPENLDAP_ADMIN_PASSWORD", "admin" );
+ private static final String OPENLDAP_CONFIG_DN = getOrDefault( "OPENLDAP_CONFIG_DN", "cn=admin,cn=config" );
+ private static final String OPENLDAP_CONFIG_PASSWORD = getOrDefault( "OPENLDAP_CONFIG_PASSWORD", "config" );
@BeforeClass
public static void skipOpenLdapTestIfNotRunning() throws Exception
@@ -132,6 +138,19 @@ public class OpenLdapTest
connection.add( entry.getEntry() );
}
}
+
+ try ( LdapNetworkConnection connection = new LdapNetworkConnection( OPENLDAP_HOST, OPENLDAP_PORT );
+ LdifReader ldifReader = new LdifReader( OpenLdapTest.class.getResourceAsStream( "OpenLdapConfig.ldif" ) ) )
+ {
+ connection.bind( OPENLDAP_CONFIG_DN, OPENLDAP_CONFIG_PASSWORD );
+ for ( LdifEntry entry : ldifReader )
+ {
+ for ( Modification modification : entry.getModifications() )
+ {
+ connection.modify( entry.getDn(), modification );
+ }
+ }
+ }
}
@@ -426,4 +445,33 @@ public class OpenLdapTest
StringUtils.countMatches( modificationLogsViewBot.getModificationLogsText(), "#!RESULT OK" ) );
}
+
+ @Test
+ public void testNoPermissionToReadSchema() throws Exception
+ {
+ // Close connection and reset cached schema
+ connectionsViewBot.closeSelectedConnections();
+ IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( connection );
+ browserConnection.setSchema( Schema.DEFAULT_SCHEMA );
+
+ // Open connection as uid=user.1 which is not allowed to read cn=subschema
+ connection.setBindPrincipal( "uid=user.1,ou=users,dc=example,dc=org" );
+ connection.setBindPassword( "password" );
+ ErrorDialogBot errorDialog = connectionsViewBot.openSelectedConnectionExpectingNoSchemaProvidedErrorDialog();
+ assertThat( errorDialog.getErrorDetails(),
+ containsString( "No schema information returned by server, using default schema." ) );
+ errorDialog.clickOkButton();
+
+ // Verify default schema is used
+ SchemaBrowserBot schemaBrowser = connectionsViewBot.openSchemaBrowser();
+ schemaBrowser.selectObjectClass( "DEFAULTSCHEMA" );
+ String rawSchemaDefinition = schemaBrowser.getRawSchemaDefinition();
+ assertNotNull( rawSchemaDefinition );
+ assertTrue( rawSchemaDefinition.contains( "This is the Default Schema" ) );
+
+ // Verify browser
+ browserViewBot.selectEntry( "DIT", "Root DSE" );
+ }
+
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
index bd7ca885e..92687ccff 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java
@@ -82,6 +82,17 @@ public class ConnectionsViewBot
}
+ public ErrorDialogBot openSelectedConnectionExpectingNoSchemaProvidedErrorDialog()
+ {
+ String shellText = BotUtils.shell( () -> {
+ JobWatcher watcher = new JobWatcher( Messages.jobs__open_connections_name_1 );
+ getConnectionsTree().contextMenu( "Open Connection" ).click();
+ watcher.waitUntilDone();
+ }, "Problem Occurred" ).getText();
+ return new ErrorDialogBot( shellText );
+ }
+
+
public void closeSelectedConnections()
{
JobWatcher watcher = new JobWatcher( Messages.jobs__close_connections_name_1 );
diff --git a/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/OpenLdapConfig.ldif b/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/OpenLdapConfig.ldif
new file mode 100644
index 000000000..f28f33888
--- /dev/null
+++ b/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/OpenLdapConfig.ldif
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+dn: olcDatabase={-1}frontend,cn=config
+changetype: modify
+replace: olcAccess
+olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external
+ ,cn=auth manage by * break
+olcAccess: {1}to dn.exact="" by * read
+olcAccess: {2}to dn.base="cn=Subschema" by dn.exact="uid=user.1,ou=users,dc=example,dc=org" none by * read
+-