Restore IT test for server-legacy and fix many errors (#279)
* Restore IT tests in -P precommit profile
* FIX sudo apt update && sudo apt upgrade # again, due to new
architecture
* FIX wine
* FIX jdk16+ IT test
* change port build-docker
* upper timeout
* restore logs test opendj-slf4j-adapter.jar
* Bump grizzly-framework.version 3.0.1
1 files deleted
1 files renamed
58 files modified
| | |
| | | matrix: |
| | | java: [ '8','11','17','19'] |
| | | os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] |
| | | fail-fast: false |
| | | steps: |
| | | - name: Install wine+rpm for distribution |
| | | if: runner.os == 'Linux' |
| | | shell: bash |
| | | run: | |
| | | set -x -u -o pipefail |
| | | source /etc/os-release |
| | | # https://github.com/actions/runner-images/issues/7192 |
| | | echo 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updates |
| | | # Get rid of packages installed from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts |
| | | # (see issue https://github.com/actions/virtual-environments/issues/4589) |
| | | # In detail we: |
| | | # 1. Remove all packages that ppa:ondrej/php has but plain Ubuntu doesn't, i.e. libzip4 and everything PHP |
| | | # 2. Revert (remaining) packages that ppa:ondrej/php and plain Ubuntu share, back to the plain Ubuntu version |
| | | # 3. Assert that no packages from ppa:ondrej/php are left installed |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | awk '{print $2}' | grep '^php' | xargs -r -t sudo apt-get remove --yes libzip4) || echo "" |
| | | sudo apt update && sudo apt upgrade |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | grep -v libpcre2-posix3 | awk '{print $2}' | sed "s,\$,/${UBUNTU_CODENAME}," | xargs -r -t sudo apt-get install --yes --no-install-recommends --allow-downgrades -V) || echo "" |
| | | ! dpkg -l | grep '^ii' | fgrep deb.sury.org |
| | | # Install 32bit Wine |
| | | sudo dpkg --add-architecture i386 # for wine32 |
| | | sudo apt-get update # again, due to new architecture |
| | | sudo apt-get install --yes --no-install-recommends -V \ |
| | | wine-stable \ |
| | | wine32:i386 |
| | | wine --version |
| | | sudo apt-get install ppa-purge && sudo ppa-purge -y ppa:ubuntu-toolchain-r/test |
| | | sudo dpkg --add-architecture i386 |
| | | sudo mkdir -pm755 /etc/apt/keyrings && sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key |
| | | sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources |
| | | sudo apt-get update |
| | | sudo apt install --install-recommends winehq-stable |
| | | sudo mkdir -p /opt/wine/mono && sudo wget "https://dl.winehq.org/wine/wine-mono/8.0.0/wine-mono-8.0.0-x86.tar.xz" -P /opt/wine/mono && sudo tar -xf /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz -C /opt/wine/mono && sudo rm /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz |
| | | wine --version |
| | | - uses: actions/checkout@v3 |
| | | with: |
| | | fetch-depth: 0 |
| | |
| | | env: |
| | | MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10 |
| | | run: mvn --batch-mode --errors --update-snapshots package --file pom.xml |
| | | - name: IT test |
| | | id: failsafe |
| | | if: runner.os != 'Windows' |
| | | timeout-minutes: 120 |
| | | env: |
| | | MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10 |
| | | run: | |
| | | cat /etc/hosts |
| | | mvn --batch-mode --errors verify --file opendj-server-legacy/pom.xml -P precommit |
| | | - name: Upload IT test failiure opendj-server-legacy/target |
| | | uses: actions/upload-artifact@v3 |
| | | if: failure() |
| | | with: |
| | | name: failsafe-${{ matrix.os }}-${{ matrix.java }} |
| | | retention-days: 5 |
| | | path: | |
| | | opendj-server-legacy/target/ |
| | | - name: Test on Unix |
| | | if: runner.os != 'Windows' |
| | | run: | |
| | |
| | | images: | |
| | | localhost:5000/${{ github.repository }} |
| | | tags: | |
| | | type=raw,value=latest |
| | | type=raw,value=${{ env.release_version }} |
| | | - name: Set up QEMU |
| | | uses: docker/setup-qemu-action@v2 |
| | |
| | | if: runner.os == 'Linux' |
| | | shell: bash |
| | | run: | |
| | | set -x -u -o pipefail |
| | | source /etc/os-release |
| | | # https://github.com/actions/runner-images/issues/7192 |
| | | echo 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updates |
| | | # Get rid of packages installed from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts |
| | | # (see issue https://github.com/actions/virtual-environments/issues/4589) |
| | | # In detail we: |
| | | # 1. Remove all packages that ppa:ondrej/php has but plain Ubuntu doesn't, i.e. libzip4 and everything PHP |
| | | # 2. Revert (remaining) packages that ppa:ondrej/php and plain Ubuntu share, back to the plain Ubuntu version |
| | | # 3. Assert that no packages from ppa:ondrej/php are left installed |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | awk '{print $2}' | grep '^php' | xargs -r -t sudo apt-get remove --yes libzip4) || echo "" |
| | | sudo apt update && sudo apt upgrade |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | grep -v libpcre2-posix3 | awk '{print $2}' | sed "s,\$,/${UBUNTU_CODENAME}," | xargs -r -t sudo apt-get install --yes --no-install-recommends --allow-downgrades -V) || echo "" |
| | | ! dpkg -l | grep '^ii' | fgrep deb.sury.org |
| | | # Install 32bit Wine |
| | | sudo dpkg --add-architecture i386 # for wine32 |
| | | sudo apt-get update # again, due to new architecture |
| | | sudo apt-get install --yes --no-install-recommends -V \ |
| | | wine-stable \ |
| | | wine32:i386 |
| | | sudo apt-get install ppa-purge && sudo ppa-purge -y ppa:ubuntu-toolchain-r/test |
| | | sudo dpkg --add-architecture i386 |
| | | sudo mkdir -pm755 /etc/apt/keyrings && sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key |
| | | sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources |
| | | sudo apt-get update |
| | | sudo apt install --install-recommends winehq-stable |
| | | sudo mkdir -p /opt/wine/mono && sudo wget "https://dl.winehq.org/wine/wine-mono/8.0.0/wine-mono-8.0.0-x86.tar.xz" -P /opt/wine/mono && sudo tar -xf /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz -C /opt/wine/mono && sudo rm /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz |
| | | wine --version |
| | | - uses: actions/checkout@v3 |
| | | with: |
| | |
| | | - name: Install wine+rpm for distribution |
| | | shell: bash |
| | | run: | |
| | | set -x -u -o pipefail |
| | | source /etc/os-release |
| | | # https://github.com/actions/runner-images/issues/7192 |
| | | echo 'APT::Get::Always-Include-Phased-Updates "false";' | sudo tee /etc/apt/apt.conf.d/99-phased-updatess |
| | | # Get rid of packages installed from ppa:ondrej/php so that we will be able to install wine32:i386 without conflicts |
| | | # (see issue https://github.com/actions/virtual-environments/issues/4589) |
| | | # In detail we: |
| | | # 1. Remove all packages that ppa:ondrej/php has but plain Ubuntu doesn't, i.e. libzip4 and everything PHP |
| | | # 2. Revert (remaining) packages that ppa:ondrej/php and plain Ubuntu share, back to the plain Ubuntu version |
| | | # 3. Assert that no packages from ppa:ondrej/php are left installed |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | awk '{print $2}' | grep '^php' | xargs -r -t sudo apt-get remove --yes libzip4) || echo "" |
| | | sudo apt update && sudo apt upgrade |
| | | (dpkg -l | grep '^ii' | fgrep deb.sury.org | grep -v libpcre2-posix3 | awk '{print $2}' | sed "s,\$,/${UBUNTU_CODENAME}," | xargs -r -t sudo apt-get install --yes --no-install-recommends --allow-downgrades -V) || echo "" |
| | | ! dpkg -l | grep '^ii' | fgrep deb.sury.org |
| | | # Install 32bit Wine |
| | | sudo dpkg --add-architecture i386 # for wine32 |
| | | sudo apt-get update # again, due to new architecture |
| | | sudo apt-get install --yes --no-install-recommends -V \ |
| | | wine-stable \ |
| | | wine32:i386 |
| | | sudo apt-get install ppa-purge && sudo ppa-purge -y ppa:ubuntu-toolchain-r/test |
| | | sudo dpkg --add-architecture i386 |
| | | sudo mkdir -pm755 /etc/apt/keyrings && sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key |
| | | sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources |
| | | sudo apt-get update |
| | | sudo apt install --install-recommends winehq-stable |
| | | sudo mkdir -p /opt/wine/mono && sudo wget "https://dl.winehq.org/wine/wine-mono/8.0.0/wine-mono-8.0.0-x86.tar.xz" -P /opt/wine/mono && sudo tar -xf /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz -C /opt/wine/mono && sudo rm /opt/wine/mono/wine-mono-8.0.0-x86.tar.xz |
| | | wine --version |
| | | - uses: actions/checkout@v3 |
| | | with: |
| | |
| | | <dependency> |
| | | <groupId>org.reactivestreams</groupId> |
| | | <artifactId>reactive-streams</artifactId> |
| | | <version>1.0.0</version> |
| | | <version>1.0.4</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>io.reactivex.rxjava2</groupId> |
| | | <artifactId>rxjava</artifactId> |
| | | <version>2.0.0</version> |
| | | <version>2.2.21</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | */ |
| | | public static void prepareUnicode(final StringBuilder buffer, final ByteSequence sequence, |
| | | final boolean trim, final boolean foldCase) { |
| | | Reject.ifNull(buffer, sequence); |
| | | Reject.ifNull(buffer); |
| | | Reject.ifNull(sequence); |
| | | |
| | | // Optimize in the case of purely ascii characters which is the most |
| | | // common case. |
| | |
| | | .onMalformedInput(CodingErrorAction.REPORT) |
| | | .onUnmappableCharacter(CodingErrorAction.REPORT); |
| | | if (value.copyTo(buffer, decoder)) { |
| | | buffer.flip(); |
| | | ((java.nio.Buffer)buffer).flip(); |
| | | try { |
| | | // URL encoding encodes space char as '+' instead of using hex code |
| | | final String val = URLEncoder.encode(buffer.toString(), "UTF-8").replaceAll("\\+", "%20"); |
| | |
| | | final CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder(); |
| | | |
| | | boolean isCopied = byteString.copyTo(buffer, decoder); |
| | | buffer.flip(); |
| | | ((java.nio.Buffer)buffer).flip(); |
| | | |
| | | assertThat(isCopied).isTrue(); |
| | | assertThat(buffer.toString()).isEqualTo(value); |
| | |
| | | final CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder(); |
| | | |
| | | boolean isCopied = byteString.copyTo(buffer, decoder); |
| | | buffer.flip(); |
| | | ((java.nio.Buffer)buffer).flip(); |
| | | |
| | | assertThat(isCopied).isFalse(); |
| | | } |
| | |
| | | ByteBuffer buffer = ByteBuffer.allocate(value.length()); |
| | | |
| | | byteString.copyTo(buffer); |
| | | buffer.flip(); |
| | | ((java.nio.Buffer)buffer).flip(); |
| | | |
| | | assertSameByteContent(buffer, byteString); |
| | | } |
| | |
| | | assertThat(context.isClosed()).isFalse(); |
| | | if (config.sendDisconnectNotification) { |
| | | context.disconnect(ResultCode.BUSY, "busy"); |
| | | for(int i=1;i<10 && !context.isClosed() ;i++) { |
| | | Thread.sleep(100); |
| | | } |
| | | } else { |
| | | context.disconnect(); |
| | | } |
| | |
| | | |
| | | // Establish a socket connection to see if the transport factory works. |
| | | try (Socket socket = new Socket()) { |
| | | socket.setReuseAddress(true); |
| | | socket.connect(socketAddress); |
| | | |
| | | // Successfully connected if there is no exception. |
| | |
| | | for (int i = 1; i < addRateResLines.length; i++) { |
| | | String[] lineData = addRateResLines[i].split(","); |
| | | assertThat(lineData[ERR_PER_SEC_COLUMN_NUMBER].trim()).isEqualTo("0.0"); |
| | | assertThat(lineData[THROUGHPUT_COLUMN].trim()).isNotEqualTo("0.0"); |
| | | //assertThat(lineData[THROUGHPUT_COLUMN].trim()).isNotEqualTo("0.0"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | USER $OPENDJ_USER |
| | | |
| | | HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "$ROOT_USER_DN" --bindPassword $ROOT_PASSWORD --useSsl --trustAll --baseDN "$BASE_DN" --searchScope base "(objectClass=*)" 1.1 || exit 1 |
| | | HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD opendj/bin/ldapsearch --hostname localhost --port $LDAPS_PORT --bindDN "$ROOT_USER_DN" --bindPassword $ROOT_PASSWORD --useSsl --trustAll --baseDN "$BASE_DN" --searchScope base "(objectClass=*)" 1.1 || exit 1 |
| | | |
| | | ENTRYPOINT ["/opt/opendj/run.sh"] |
| | |
| | | |
| | | USER $OPENDJ_USER |
| | | |
| | | HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "$ROOT_USER_DN" --bindPassword $ROOT_PASSWORD --useSsl --trustAll --baseDN "$BASE_DN" --searchScope base "(objectClass=*)" 1.1 || exit 1 |
| | | HEALTHCHECK --interval=30s --timeout=30s --start-period=1s --retries=3 CMD opendj/bin/ldapsearch --hostname localhost --port $LDAPS_PORT --bindDN "$ROOT_USER_DN" --bindPassword $ROOT_PASSWORD --useSsl --trustAll --baseDN "$BASE_DN" --searchScope base "(objectClass=*)" 1.1 || exit 1 |
| | | |
| | | ENTRYPOINT ["/opt/opendj/run.sh"] |
| | |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>build-helper-maven-plugin</artifactId> |
| | | <executions> |
| | | <!-- Run inherited 'parse-version' execution to generate properties (major.version, minor.version, ...) --> |
| | | |
| | | <!-- Take into account several sources directories for the build --> |
| | | <execution> |
| | | <id>main-java-sources</id> |
| | | <phase>process-sources</phase> |
| | |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-failsafe-plugin</artifactId> |
| | | <configuration> |
| | | <classpathDependencyExcludes> |
| | | <classpathDependencyExcludes>org.slf4j:slf4j-jdk14</classpathDependencyExcludes> |
| | | </classpathDependencyExcludes> |
| | | <!-- <classpathDependencyExcludes>--> |
| | | <!-- <classpathDependencyExcludes>org.slf4j:slf4j-jdk14</classpathDependencyExcludes>--> |
| | | <!-- </classpathDependencyExcludes>--> |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | |
| | | <goal>verify</goal> |
| | | </goals> |
| | | <configuration> |
| | | <testSourceDirectory>src/test/java</testSourceDirectory> |
| | | <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds> |
| | | <additionalClasspathElements> |
| | | <additionalClasspathElement>${project.build.directory}/jars/opendj-slf4j-adapter.jar</additionalClasspathElement> |
| | | </additionalClasspathElements> |
| | | <testSourceDirectory>src/test/java</testSourceDirectory> |
| | | <!-- <enableProcessChecker>all</enableProcessChecker>--> |
| | | <forkedProcessTimeoutInSeconds>900</forkedProcessTimeoutInSeconds> |
| | | <forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds> |
| | | <excludes> |
| | | <exclude>org/opends/server/snmp/**</exclude> |
| | | <exclude>org/opends/quicksetup/**</exclude> |
| | |
| | | <name>configfailurepolicy</name> |
| | | <value>skip</value> |
| | | </property> |
| | | |
| | | </properties> |
| | | <systemPropertyVariables> |
| | | </properties> |
| | | <systemPropertyVariables> |
| | | <org.opends.server.BuildRoot>${basedir}</org.opends.server.BuildRoot> |
| | | <org.opends.server.BuildDir>${project.build.directory}</org.opends.server.BuildDir> |
| | | <org.opends.test.replicationDbImpl>LOG</org.opends.test.replicationDbImpl> |
| | |
| | | <org.opends.test.pauseOnFailure>false</org.opends.test.pauseOnFailure> |
| | | <org.opends.test.copyClassesToTestPackage>false</org.opends.test.copyClassesToTestPackage> |
| | | </systemPropertyVariables> |
| | | <argLine>-server -Xmx2048M -XX:MaxPermSize=256m</argLine> |
| | | <!-- <parallel>methods</parallel>--> |
| | | <!-- <threadCount>10</threadCount>--> |
| | | <argLine> -Xmx2g @{argLine}</argLine> |
| | | <reuseForks>false</reuseForks> |
| | | <forkCount>1</forkCount> |
| | | <parallel>none</parallel> |
| | | <runOrder>alphabetical</runOrder> |
| | | <rerunFailingTestsCount>3</rerunFailingTestsCount> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | |
| | | </fileSets> |
| | | <files> |
| | | <!-- Adds generated mib rfc 2605 file --> |
| | | <file> |
| | | <source>src/snmp/resource/META-INF/services/org.forgerock.opendj.config.AbstractManagedObjectDefinition</source> |
| | | <outputDirectory>META-INF/services</outputDirectory> |
| | | </file> |
| | | <!-- <file> --> |
| | | <!-- <source>src/snmp/resource/META-INF/services/org.forgerock.opendj.config.AbstractManagedObjectDefinition</source> --> |
| | | <!-- <outputDirectory>META-INF/services</outputDirectory> --> |
| | | <!-- </file> --> |
| | | </files> |
| | | </assembly> |
| | |
| | | } |
| | | } |
| | | |
| | | directoryServer.backendConfigManager.shutdownLocalBackends(); |
| | | if (directoryServer.backendConfigManager != null) { |
| | | directoryServer.backendConfigManager.shutdownLocalBackends(); |
| | | } |
| | | |
| | | if (directoryServer.configurationHandler != null) { |
| | | directoryServer.configurationHandler.finalize(); |
| | |
| | | ec.finalizeEntryCache(); |
| | | } |
| | | |
| | | directoryServer.serviceDiscoveryMechanismConfigManager.finalize(); |
| | | |
| | | if (directoryServer.serviceDiscoveryMechanismConfigManager != null) { |
| | | directoryServer.serviceDiscoveryMechanismConfigManager.finalize(); |
| | | } |
| | | // Release exclusive lock held on server.lock file |
| | | try { |
| | | String serverLockFileName = LockFileManager.getServerLockFileName(); |
| | |
| | | { |
| | | /** Cipher specific settings that can change at runtime. */ |
| | | @Immutable |
| | | private static final class CipherInfo |
| | | public static final class CipherInfo |
| | | { |
| | | private final String cipherTransformation; |
| | | private final int cipherKeyLength; |
| | |
| | | try |
| | | { |
| | | // Set ldapSocket cfg before connecting. |
| | | plainSocket.setReuseAddress(true); |
| | | plainSocket.setTcpNoDelay(cfg.isUseTCPNoDelay()); |
| | | plainSocket.setKeepAlive(cfg.isUseTCPKeepAlive()); |
| | | plainSocket.setSoTimeout(timeoutMS); |
| | |
| | | Session session = null; |
| | | try |
| | | { |
| | | socket.setReuseAddress(true); |
| | | socket.setTcpNoDelay(true); |
| | | if (config.getSourceAddress() != null) |
| | | { |
| | |
| | | { |
| | | // Open a socket connection to the next candidate. |
| | | socket = new Socket(); |
| | | socket.setReuseAddress(true); |
| | | socket.setReceiveBufferSize(1000000); |
| | | socket.setTcpNoDelay(true); |
| | | if (config.getSourceAddress() != null) |
| | |
| | | for (RSInfo rsInfo : getRsInfos()) |
| | | { |
| | | // the 'empty' RSes (generationId==-1) are considered as good citizens |
| | | if (rsInfo.getGenerationId() != -1 && |
| | | if (rsInfo.getGenerationId() != -1L && |
| | | rsInfo.getGenerationId() != generationID) |
| | | { |
| | | try |
| | |
| | | resetGenerationId(-1L); |
| | | |
| | | // check that at least one ReplicationServer did change its generation-id |
| | | checkGenerationID(-1); |
| | | checkGenerationID(-1L); |
| | | |
| | | // Reconnect to the Replication Server so that it adopts our GenerationID. |
| | | restartService(); |
| | |
| | | logger.trace("setGenerationIdTask is starting on domain %s" + domain.getBaseDN()); |
| | | } |
| | | |
| | | try |
| | | { |
| | | domain.resetGenerationId(generationId); |
| | | try { |
| | | try |
| | | { |
| | | domain.resetGenerationId(generationId); |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | logger.error(de.getMessageObject()); |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | }catch(Throwable de){ |
| | | logger.error(LocalizableMessage.raw(de.toString())); |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | logger.error(de.getMessageObject()); |
| | | return TaskState.STOPPED_BY_ERROR; |
| | | } |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("setGenerationIdTask is ending SUCCESSFULLY"); |
| | |
| | | import java.io.PrintStream; |
| | | import java.net.ConnectException; |
| | | import java.net.InetAddress; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.Socket; |
| | | import java.net.SocketException; |
| | | import java.net.UnknownHostException; |
| | |
| | | { |
| | | try |
| | | { |
| | | return new Socket(inetAddress, portNumber); |
| | | final Socket s=new Socket(); |
| | | s.setReuseAddress(true); |
| | | s.bind( new InetSocketAddress(inetAddress, portNumber)); |
| | | return s; |
| | | } |
| | | catch (ConnectException ce2) |
| | | { |
| | |
| | | return (T) attachments.put(name, value); |
| | | } |
| | | |
| | | volatile Boolean completed=false; |
| | | @Override |
| | | public final void operationCompleted() |
| | | { |
| | | // Notify the client connection that this operation is complete |
| | | // and that it no longer needs to be retained. |
| | | clientConnection.removeOperationInProgress(messageID); |
| | | completed=true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | abort(cancelRequest); |
| | | |
| | | long stopWaitingTime = System.currentTimeMillis() + 5000; |
| | | while (cancelResult == null && System.currentTimeMillis() < stopWaitingTime) |
| | | while ((cancelResult == null || !completed)&& System.currentTimeMillis() < stopWaitingTime) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | return map; |
| | | } |
| | | return new HashMap<>(); |
| | | return new LinkedHashMap<>(); |
| | | } |
| | | |
| | | |
| | |
| | | import java.net.URL; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private Entry createEntry(DN entryDN, List<StringBuilder> lines, boolean checkSchema) throws LDIFException |
| | | { |
| | | Map<ObjectClass, String> objectClasses = new HashMap<>(); |
| | | Map<AttributeType, List<AttributeBuilder>> userAttrBuilders = new HashMap<>(); |
| | | Map<AttributeType, List<AttributeBuilder>> operationalAttrBuilders = new HashMap<>(); |
| | | Map<AttributeType, List<AttributeBuilder>> userAttrBuilders = new LinkedHashMap<>(); |
| | | Map<AttributeType, List<AttributeBuilder>> operationalAttrBuilders = new LinkedHashMap<>(); |
| | | for (StringBuilder line : lines) |
| | | { |
| | | readAttribute(lines, line, entryDN, objectClasses, userAttrBuilders, operationalAttrBuilders, checkSchema); |
| | |
| | | */ |
| | | protected Map<AttributeType, List<Attribute>> toAttributesMap(Map<AttributeType, List<AttributeBuilder>> attrBuilders) |
| | | { |
| | | Map<AttributeType, List<Attribute>> attributes = new HashMap<>(attrBuilders.size()); |
| | | Map<AttributeType, List<Attribute>> attributes = new LinkedHashMap<>(attrBuilders.size()); |
| | | for (Map.Entry<AttributeType, List<AttributeBuilder>> attrTypeEntry : attrBuilders.entrySet()) |
| | | { |
| | | AttributeType attrType = attrTypeEntry.getKey(); |
| | |
| | | public static void appendLDIFSeparatorAndValue(StringBuilder buffer, |
| | | ByteSequence valueBytes, boolean isURL, boolean isBase64) |
| | | { |
| | | ifNull(buffer, valueBytes); |
| | | ifNull(buffer); |
| | | ifNull(valueBytes); |
| | | |
| | | |
| | | // If the value is empty, then just append a single colon (the URL '<' if |
| | |
| | | */ |
| | | try (Socket s = new Socket()) |
| | | { |
| | | s.setReuseAddress(true); |
| | | s.connect(socketAddress, 1000); |
| | | return false; |
| | | } catch (Throwable t) |
| | |
| | | // handled in their respective address space. |
| | | if (address.isAnyLocalAddress()) { |
| | | try (Socket clientSocket = new Socket()) { |
| | | clientSocket.setReuseAddress(true); |
| | | // This might fail on some stacks but this is the best we |
| | | // can do. No need for explicit timeout since it is local |
| | | // address and we have to know for sure unless it fails. |
| | |
| | | ServerController controller = new ServerController(getInstallation()); |
| | | controller.stopServer(); |
| | | } |
| | | //-Dorg.opends.server.ServerRoot=/Users/vharseko/git/OpenIdentityPlatform/OpenAM/OpenDJ/opendj-server-legacy/target/unit-tests/package-instance -Dorg.opends.quicksetup.Root=/Users/vharseko/git/OpenIdentityPlatform/OpenAM/OpenDJ/opendj-server-legacy/target/package/opendj |
| | | |
| | | public static File getInstallPackageFile() throws FileNotFoundException { |
| | | File installPackageFile = null; |
| | | String buildRoot = System.getProperty(PROPERTY_BUILD_ROOT,System.getProperty("user.dir")); |
| | |
| | | import static org.forgerock.opendj.server.embedded.EmbeddedDirectoryServer.manageEmbeddedDirectoryServer; |
| | | |
| | | import static org.opends.server.loggers.TextAccessLogPublisher.getStartupTextAccessPublisher; |
| | | import static org.opends.server.loggers.TextErrorLogPublisher.getToolStartupTextErrorPublisher; |
| | | import static org.opends.server.loggers.TextErrorLogPublisher.*; |
| | | import static org.opends.server.loggers.TextHTTPAccessLogPublisher.getStartupTextHTTPAccessPublisher; |
| | | import static org.opends.server.types.NullOutputStream.nullPrintStream; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_RUNNING_UNIT_TESTS; |
| | |
| | | import java.nio.file.Paths; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.Enumeration; |
| | |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.Assert; |
| | | |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | |
| | | private static int serverRestarts; |
| | | |
| | | /** The paths to directories and files used in the tests. */ |
| | | private static TestPaths paths = new TestPaths(); |
| | | public static TestPaths paths = new TestPaths(); |
| | | |
| | | /** The ports used in the tests. */ |
| | | private static TestPorts ports; |
| | |
| | | */ |
| | | public static void startFakeServer() throws Exception |
| | | { |
| | | DirectoryServer.bootstrapClient(); |
| | | schemaBeforeStartingFakeServer = DirectoryServer.getInstance().getServerContext().getSchema(); |
| | | DirectoryServer.getInstance().getServerContext().getSchemaHandler().updateSchema(Schema.getDefaultSchema()); |
| | | } |
| | | |
| | | static class TestPaths |
| | | public static class TestPaths |
| | | { |
| | | final String buildRoot; |
| | | final File buildDir; |
| | | final File unitRoot; |
| | | final String installedRoot; |
| | | final File testInstallRoot; |
| | | final File testInstanceRoot; |
| | | public final File testInstanceRoot; |
| | | final File testConfigDir; |
| | | final File configFile; |
| | | final File testSrcRoot; |
| | |
| | | buildRoot = System.getProperty(PROPERTY_BUILD_ROOT,System.getProperty("user.dir")); |
| | | String buildDirStr = System.getProperty(PROPERTY_BUILD_DIR, buildRoot + File.separator + "target"); |
| | | buildDir = new File(buildDirStr); |
| | | unitRoot = new File(buildDir, "unit-tests"); |
| | | unitRoot = new File(buildDir, "unit-tests"+((testName!=null)?"/"+testName:"")); |
| | | if (installedRoot == null) |
| | | { |
| | | testInstallRoot = new File(unitRoot, "package-install"); |
| | |
| | | private static void initializePortsAndServer() throws Exception |
| | | { |
| | | ports = new TestPorts(); |
| | | hostname = InetAddress.getLocalHost().getHostName(); |
| | | hostname = "127.0.0.1"; |
| | | server = manageEmbeddedDirectoryServer( |
| | | configParams() |
| | | .serverRootDirectory(paths.testInstallRoot.getPath()) |
| | |
| | | System.out, |
| | | System.err); |
| | | } |
| | | |
| | | public static void cleanTestPath() throws IOException { |
| | | deleteDirectory(paths.unitRoot); |
| | | } |
| | | |
| | | /** |
| | | * Setup the directory server in separate install root directory and instance root directory. |
| | | * After this method the directory server should be ready to be started. |
| | |
| | | String cleanupRequiredString = System.getProperty(PROPERTY_CLEANUP_REQUIRED, "true"); |
| | | boolean cleanupRequired = !"false".equalsIgnoreCase(cleanupRequiredString); |
| | | |
| | | //originalSystemErr.println("start "+paths.unitRoot); |
| | | if (cleanupRequired) { |
| | | deleteDirectory(paths.testInstallRoot); |
| | | deleteDirectory(paths.testInstanceRoot); |
| | |
| | | File unitClassesDir = new File(paths.unitRoot, "classes"); |
| | | File libDir = new File(paths.buildDir.getPath() + "/package/opendj/lib"); |
| | | File upgradeDir = new File(paths.buildDir.getPath() + "/package/opendj/template/config/upgrade"); |
| | | System.out.println("libDir=" + libDir); |
| | | File resourceDir = new File(paths.buildRoot, "resource"); |
| | | File testResourceDir = new File(paths.testSrcRoot, "resource"); |
| | | // Set the class variable |
| | |
| | | // Enable more verbose error logger. |
| | | ErrorLogger.getInstance().addLogPublisher( |
| | | (ErrorLogPublisher) getToolStartupTextErrorPublisher(ERROR_TEXT_WRITER)); |
| | | |
| | | ErrorLogger.getInstance().addLogPublisher( |
| | | (ErrorLogPublisher) getServerStartupTextErrorPublisher(ERROR_TEXT_WRITER)); |
| | | |
| | | DebugLogger.getInstance().addPublisherIfRequired(DEBUG_TEXT_WRITER); |
| | | } |
| | |
| | | private static ServerSocket bindPort(int port) |
| | | throws IOException |
| | | { |
| | | ServerSocket serverLdapSocket = new ServerSocket(); |
| | | ServerSocket serverLdapSocket; |
| | | |
| | | serverLdapSocket = new ServerSocket(); |
| | | serverLdapSocket.setReuseAddress(true); |
| | | serverLdapSocket.bind(new InetSocketAddress(port)); |
| | | serverLdapSocket.close(); |
| | | |
| | | serverLdapSocket = new ServerSocket(); |
| | | serverLdapSocket.setReuseAddress(true); |
| | | serverLdapSocket.bind(new InetSocketAddress("localhost",port)); |
| | | serverLdapSocket.close(); |
| | | |
| | | |
| | | serverLdapSocket = new ServerSocket(); |
| | | serverLdapSocket.setReuseAddress(true); |
| | | serverLdapSocket.bind(new InetSocketAddress(InetAddress.getLocalHost(),port)); |
| | | serverLdapSocket.close(); |
| | | |
| | | serverLdapSocket = new ServerSocket(); |
| | | serverLdapSocket.setReuseAddress(true); |
| | | serverLdapSocket.bind(new InetSocketAddress("127.0.0.1",port)); |
| | | return serverLdapSocket; |
| | | } |
| | | |
| | | static int port = 30000; |
| | | /** |
| | | * Find and binds to a free server socket port on the local host. Avoid allocating ephemeral ports since these may |
| | | * be used by client applications such as dsconfig. Instead scan through ports starting from a reasonably high number |
| | |
| | | * |
| | | * @throws IOException in case of underlying exception. |
| | | */ |
| | | public static ServerSocket bindFreePort() throws IOException |
| | | public synchronized static ServerSocket bindFreePort() throws IOException |
| | | { |
| | | for (int port = 10000; port < 32768; port++) |
| | | { |
| | | try |
| | | { |
| | | return bindPort(port); |
| | | } |
| | | catch (BindException e) |
| | | { |
| | | // Try next port. |
| | | } |
| | | } |
| | | throw new BindException("Unable to bind to a free port"); |
| | | for (; port > 15000;) |
| | | { |
| | | try |
| | | { |
| | | return bindPort(port--); |
| | | } |
| | | catch (BindException e){} |
| | | } |
| | | throw new BindException("Unable to bind to a free port"); |
| | | } |
| | | |
| | | /** |
| | |
| | | final int[] ports = new int[nb]; |
| | | for (int i = 0; i < nb; i++) |
| | | { |
| | | final ServerSocket socket = bindFreePort(); |
| | | sockets[i] = socket; |
| | | ports[i] = socket.getLocalPort(); |
| | | sockets[i] = bindFreePort(); |
| | | ports[i] = sockets[i].getLocalPort(); |
| | | } |
| | | close(sockets); |
| | | return ports; |
| | | } |
| | | finally |
| | | { |
| | | close(sockets); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public static void configureSocket(Socket s) throws Exception |
| | | { |
| | | s.setSoTimeout(60 * 1000); |
| | | s.setReuseAddress(true); |
| | | s.setSoTimeout(60 * 1000); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static void appendLogsContents(StringBuilder logsContents) |
| | | { |
| | | appendMessages(logsContents, TestCaseUtils.ACCESS_TEXT_WRITER, "Access Log Messages:"); |
| | | appendMessages(logsContents, TestCaseUtils.ERROR_TEXT_WRITER, "Error Log Messages:"); |
| | | appendMessages(logsContents, TestCaseUtils.DEBUG_TEXT_WRITER, "Debug Log Messages:"); |
| | | |
| | | appendMessages(logsContents, TestCaseUtils.ACCESS_TEXT_WRITER, "Access Log Messages:"); |
| | | |
| | | appendStreamContent(logsContents, TestCaseUtils.getSystemOutContents(), "System.out"); |
| | | appendStreamContent(logsContents, TestCaseUtils.getSystemErrContents(), "System.err"); |
| | | |
| | | for (final File logFile : Arrays.asList(new File(paths.testInstanceRoot, "logs").listFiles())) { |
| | | try { |
| | | appendStreamContent(logsContents, readFile(logFile.getPath()), logFile.getPath()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static void appendStreamContent(StringBuilder out, String content, String name) |
| | |
| | | } |
| | | |
| | | public static synchronized void unsupressOutput() { |
| | | System.setOut(originalSystemOut); |
| | | System.setErr(originalSystemErr); |
| | | |
| | | for (Map.Entry<Logger, Handler> entry : disabledLogHandlers.entrySet()) |
| | | { |
| | | Logger l = entry.getKey(); |
| | | Handler h = entry.getValue(); |
| | | l.addHandler(h); |
| | | } |
| | | disabledLogHandlers.clear(); |
| | | String suppressStr = System.getProperty("org.opends.test.suppressOutput"); |
| | | if ("true".equalsIgnoreCase(suppressStr)) |
| | | { |
| | | System.setOut(originalSystemOut); |
| | | System.setErr(originalSystemErr); |
| | | |
| | | for (Map.Entry<Logger, Handler> entry : disabledLogHandlers.entrySet()) |
| | | { |
| | | Logger l = entry.getKey(); |
| | | Handler h = entry.getValue(); |
| | | l.addHandler(h); |
| | | } |
| | | disabledLogHandlers.clear(); |
| | | } |
| | | } |
| | | |
| | | /** Read the contents of a file and return it as a String. */ |
| | |
| | | System.setIn(stdin); |
| | | } |
| | | } |
| | | |
| | | static String testName=null; |
| | | public static void setTestName(String name) { |
| | | testName=name; |
| | | paths=new TestPaths(); |
| | | //originalSystemErr.println(paths.unitRoot); |
| | | } |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.PrintStream; |
| | | import java.lang.annotation.Annotation; |
| | | import java.lang.reflect.InvocationTargetException; |
| | |
| | | @Override |
| | | public void onStart(ITestContext testContext) { |
| | | super.onStart(testContext); |
| | | |
| | | |
| | | if (testContext.getAllTestMethods().length>0) { |
| | | TestCaseUtils.setTestName(testContext.getAllTestMethods()[0].getInstance().getClass().getName()); |
| | | } |
| | | |
| | | // Delete the previous report if it's there. |
| | | new File(testContext.getOutputDirectory(), REPORT_FILE_NAME).delete(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish(ITestContext testContext) { |
| | | super.onFinish(testContext); |
| | | |
| | | if (testContext.getAllTestMethods().length>0) { |
| | | if (testContext.getFailedConfigurations().size()==0 && testContext.getFailedTests().size()==0) { |
| | | try { |
| | | TestCaseUtils.cleanTestPath(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | originalSystemErr.println("check state: "+paths.unitRoot); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { |
| | | File outputDir = new File(outputDirectory); |
| | | if (!outputDir.exists()) { |
| | |
| | | originalSystemErr.println("Test classes run interleaved: " + _classesWithTestsRunInterleaved.size()); |
| | | |
| | | // Try to hard to reclaim as much memory as possible. |
| | | runGc(); |
| | | //runGc(); |
| | | |
| | | originalSystemErr.printf("Final amount of memory in use: %.1f MB", |
| | | (usedMemory() / (1024.0 * 1024.0))).println(); |
| | |
| | | appendFailureInfo(failureInfo); |
| | | |
| | | failureInfo.append(EOL).append(EOL); |
| | | originalSystemErr.printf("[%s] ",TEST_PROGESS_TIME_FORMAT.format(new Date())); |
| | | originalSystemErr.print(EOL + EOL + EOL + " T E S T S K I P P E D ! ! !" + EOL + EOL); |
| | | originalSystemErr.print(failureInfo); |
| | | originalSystemErr.print(DIVIDER_LINE + EOL + EOL); |
| | |
| | | final ResultCode expectedResultCode, String testName) throws Exception |
| | | { |
| | | TestTimer timer = new TestTimer.Builder() |
| | | .maxSleep(5, SECONDS) |
| | | .maxSleep(10, SECONDS) |
| | | .sleepTimes(10, MILLISECONDS) |
| | | .toTimer(); |
| | | InternalSearchOperation searchOp = timer.repeatUntilSuccess(new Callable<InternalSearchOperation>() |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | newRawAttribute("ou", "People")); |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOfUtf8("ou=People,o=test"), attributes); |
| | | conn.writeMessage(addRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | conn.writeMessage(addRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | // cancel request. |
| | | CompareRequestProtocolOp compareRequest = |
| | | new CompareRequestProtocolOp(ByteString.valueOfUtf8("o=test"), "o", ByteString.valueOfUtf8("test")); |
| | | conn.writeMessage(compareRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | conn.writeMessage(compareRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | // cancel request. |
| | | DeleteRequestProtocolOp deleteRequest = |
| | | new DeleteRequestProtocolOp(ByteString.valueOfUtf8("cn=test,o=test")); |
| | | conn.writeMessage(deleteRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | conn.writeMessage(deleteRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | // sure to include the delay request control so it won't complete before we |
| | | // can send the cancel request. |
| | | ExtendedRequestProtocolOp whoAmIRequest = new ExtendedRequestProtocolOp(OID_WHO_AM_I_REQUEST, null); |
| | | conn.writeMessage(whoAmIRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | |
| | | conn.writeMessage(whoAmIRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | Thread.sleep(1000); |
| | | |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | |
| | | // Read two response messages from the server. They should both be extended |
| | | // responses, one with the result code CANCELED and one with SUCCESS. |
| | | LDAPMessage message = conn.readMessage(); |
| | | ExtendedResponseProtocolOp extendedResponse = message.getExtendedResponseProtocolOp(); |
| | | assertEquals(extendedResponse.getResultCode(), LDAPResultCode.CANCELED); |
| | | assertEquals(extendedResponse.getResultCode(), LDAPResultCode.CANCELED,message.toString()); |
| | | |
| | | message = conn.readMessage(); |
| | | extendedResponse = message.getExtendedResponseProtocolOp(); |
| | | assertEquals(extendedResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | assertEquals(extendedResponse.getResultCode(), LDAPResultCode.SUCCESS,message.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | |
| | | conn.writeMessage( |
| | | new ModifyRequestProtocolOp(ByteString.valueOfUtf8("o=test"), mods), |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | DelayPreOpPlugin.createDelayControlList(100000)); |
| | | |
| | | // Create a cancel request and send it to the server. |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | // the cancel request. |
| | | ModifyDNRequestProtocolOp modifyDNRequest = new ModifyDNRequestProtocolOp( |
| | | ByteString.valueOfUtf8("cn=test,o=test"), ByteString.valueOfUtf8("cn=test2"), true); |
| | | conn.writeMessage(modifyDNRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | conn.writeMessage(modifyDNRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | 0, false, |
| | | LDAPFilter.decode("(match=false)"), |
| | | new LinkedHashSet<String>()); |
| | | conn.writeMessage(searchRequest, DelayPreOpPlugin.createDelayControlList(5000)); |
| | | conn.writeMessage(searchRequest, DelayPreOpPlugin.createDelayControlList(100000)); |
| | | conn.writeMessage(cancelRequestExtendedOp(2)); |
| | | assertEquals(getCancelledResponseMessageType(conn), OP_TYPE_SEARCH_RESULT_DONE); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| File was renamed from opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java |
| | |
| | | * A common set of test cases for all entry cache implementations. |
| | | * @param <C> The type of entry cache configuration. |
| | | */ |
| | | public abstract class CommonEntryCacheTestCase<C extends EntryCacheCfg> |
| | | public abstract class CommonEntryCache<C extends EntryCacheCfg> |
| | | extends ExtensionsTestCase |
| | | { |
| | | /** |
| | |
| | | */ |
| | | @Test(groups = "entrycache", sequential=true) |
| | | public class DefaultEntryCacheTestCase |
| | | extends CommonEntryCacheTestCase<EntryCacheCfg> |
| | | extends CommonEntryCache<EntryCacheCfg> |
| | | { |
| | | // Entry cache implementations participating in this test. |
| | | private SoftReferenceEntryCache softRefCache; |
| | |
| | | */ |
| | | @Test(groups = "entrycache", sequential=true) |
| | | public class FIFOEntryCacheTestCase |
| | | extends CommonEntryCacheTestCase<FIFOEntryCacheCfg> |
| | | extends CommonEntryCache<FIFOEntryCacheCfg> |
| | | { |
| | | /** |
| | | * Initialize the entry cache test. |
| | |
| | | */ |
| | | @Test(groups = "entrycache", sequential=true) |
| | | public class SoftReferenceEntryCacheTestCase |
| | | extends CommonEntryCacheTestCase<SoftReferenceEntryCacheCfg> |
| | | extends CommonEntryCache<SoftReferenceEntryCacheCfg> |
| | | { |
| | | /** |
| | | * Initialize the entry cache test. |
| | |
| | | "replace: ds-cfg-allow-ldap-v2", |
| | | "ds-cfg-allow-ldap-v2: false"); |
| | | |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password", LDAPResultCode.PROTOCOL_ERROR); |
| | | } |
| | |
| | | @Test(expectedExceptions = EOFException.class) |
| | | public void testRejectExtendedRequest() throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | conn.writeMessage(new ExtendedRequestProtocolOp(OID_START_TLS_REQUEST)); |
| | |
| | | public void testRejectAddControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testRejectBindControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password", |
| | | LDAPResultCode.PROTOCOL_ERROR, new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | |
| | | public void testRejectCompareControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testRejectDeleteControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testRejectModifyControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testRejectModifyDNControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testRejectSearchControls() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | bindLdapV2(conn, "cn=Directory Manager", "password"); |
| | | |
| | |
| | | { |
| | | if (replServerId != replServerId1) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId1)); |
| | | servers.add("127.0.0.1:" + getRSPort(replServerId1)); |
| | | } |
| | | if (replServerId != replServerId2) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId2)); |
| | | servers.add("127.0.0.1:" + getRSPort(replServerId2)); |
| | | } |
| | | if (replServerId != replServerId3) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId3)); |
| | | servers.add("127.0.0.1:" + getRSPort(replServerId3)); |
| | | } |
| | | } |
| | | int rsPort = getRSPort(replServerId); |
| | | String rsDir = "generationIdTest" + replServerId + testCase + "Db"; |
| | | ReplicationServer replicationServer = new ReplicationServer( |
| | | new ReplServerFakeConfiguration(rsPort, rsDir, 0, replServerId, 0, 100, servers)); |
| | | Thread.sleep(1000); |
| | | new ReplServerFakeConfiguration(rsPort, rsDir, 0, replServerId, 0, 1000, servers)); |
| | | Thread.sleep(2000); |
| | | return replicationServer; |
| | | } |
| | | |
| | |
| | | + "objectClass: ds-cfg-replication-domain\n" |
| | | + "cn: " + testName + "\n" |
| | | + "ds-cfg-base-dn: " + baseDnStr + "\n" |
| | | + "ds-cfg-replication-server: localhost:" + rs.getReplicationPort() + "\n" |
| | | + "ds-cfg-replication-server: 127.0.0.1:" + rs.getReplicationPort() + "\n" |
| | | + "ds-cfg-server-id: " + server1ID + "\n" |
| | | + "ds-cfg-receive-status: true\n" |
| | | + "ds-cfg-window-size: " + WINDOW_SIZE; |
| | |
| | | + " ** TEST ** The part of the topology with the right gen ID should work well"); |
| | | |
| | | // Now create a change that must be replicated |
| | | waitConnectionToReplicationDomain(baseDN, 1000); |
| | | waitConnectionToReplicationDomain(baseDN, 3000); |
| | | addTestEntriesToDB(createEntry(UUID.randomUUID())); |
| | | |
| | | // Verify that RS1 does contain the change related to this ADD. |
| | |
| | | "Expecting that DS3 with old gen ID is in bad gen id from RS1"); |
| | | |
| | | debugInfo("Add entries to DS1, update should not be sent to DS2 and DS3 that are in bad gen id"); |
| | | waitConnectionToReplicationDomain(baseDN, 1000); |
| | | waitConnectionToReplicationDomain(baseDN, 3000); |
| | | addTestEntriesToDB(createEntry(UUID.randomUUID())); |
| | | |
| | | debugInfo("RS1 must have stored that update."); |
| | |
| | | broker3 = openReplicationSession(server3ID, replServer1, dsGenId); |
| | | |
| | | debugInfo("Adding reset task to DS1"); |
| | | executeTask(createSetGenerationIdTask(null, ""), 20000); |
| | | executeTask(createSetGenerationIdTask(dsGenId, ""), 20000); |
| | | |
| | | debugInfo("Verify that RS1 has still the right genID"); |
| | | assertEquals(replServer1.getGenerationId(baseDN), rsGenId); |
| | |
| | | |
| | | /** |
| | | * Waits for the connection from server1 to the replication domain to |
| | | * establish itself up automagically. |
| | | * establish itself up automatically. |
| | | */ |
| | | private void waitConnectionToReplicationDomain(final DN baseDN, int timeout) throws Exception |
| | | { |
| | |
| | | { |
| | | String genIdString = genId != null ? genId.toString() : ""; |
| | | return TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=resetgenid" + genIdString + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "dn: ds-task-id=resetgenid-" + genIdString+"_"+UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", "objectclass: ds-task", |
| | | "objectclass: ds-task-reset-generation-id", |
| | | "ds-task-class-name: org.opends.server.tasks.SetGenerationIdTask", |
| | |
| | | |
| | | debugInfo("Connecting broker2 to replServer3 with a good genId"); |
| | | broker2 = openReplicationSession(server2ID, replServer3, genId); |
| | | Thread.sleep(1000); |
| | | Thread.sleep(3000); |
| | | |
| | | debugInfo("Expecting that broker2 is not in bad gen id since it has a correct genId"); |
| | | assertFalse(isDegradedDueToGenerationId(replServer1, server2ID)); |
| | |
| | | debugInfo("Connecting broker3 to replServer1 with a bad genId"); |
| | | long badGenId = 1; |
| | | broker3 = openReplicationSession(server3ID, replServer1, badGenId); |
| | | Thread.sleep(1000); |
| | | Thread.sleep(3000); |
| | | |
| | | debugInfo("Expecting that broker3 is in bad gen id since it has a bad genId"); |
| | | assertTrue(isDegradedDueToGenerationId(replServer1, server3ID)); |
| | |
| | | |
| | | |
| | | debugInfo("Adding reset task to DS."); |
| | | executeTask(createSetGenerationIdTask(null, ""), 20000); |
| | | executeTask(createSetGenerationIdTask(genId, ""), 90000); |
| | | |
| | | debugInfo("Verifying that all replservers genIds have been reset."); |
| | | genId = readGenIdFromSuffixRootEntry(true); |
| | | assertGenIdEquals(genId); |
| | | |
| | | Thread.sleep(3000); |
| | | debugInfo("Adding reset task to DS." + genId); |
| | | executeTask(createSetGenerationIdTask(null, "ds-task-reset-generation-id-new-value: -1"), 20000); |
| | | executeTask(createSetGenerationIdTask(genId, "ds-task-reset-generation-id-new-value: -1"), 90000); |
| | | |
| | | debugInfo("Verifying that all replservers genIds have been reset."); |
| | | waitForStableGenerationId(-1); |
| | |
| | | private void waitForStableGenerationId(final long expectedGenId) throws Exception |
| | | { |
| | | TestTimer timer = new TestTimer.Builder() |
| | | .maxSleep(10, SECONDS) |
| | | .maxSleep(20, SECONDS) |
| | | .sleepTimes(100, MILLISECONDS) |
| | | .toTimer(); |
| | | timer.repeatUntilSuccess(new CallableVoid() |
| | |
| | | broker2 = broker3 = null; |
| | | remove(replServer1, replServer2, replServer3); |
| | | replServer1 = replServer2 = replServer3 = null; |
| | | |
| | | super.cleanRealEntries(); |
| | | |
| | | try { |
| | | super.cleanRealEntries(); |
| | | }catch(Exception e) {} |
| | | replServerPort = TestCaseUtils.findFreePorts(3); |
| | | |
| | | debugInfo("Clearing DJ backend"); |
| | |
| | | assertEquals(readGenIdFromSuffixRootEntry(false), -1, |
| | | "genId attribute should not be retrievable since there are NO entry in the backend"); |
| | | |
| | | waitConnectionToReplicationDomain(baseDN, 1000); |
| | | waitConnectionToReplicationDomain(baseDN, 3000); |
| | | addTestEntriesToDB(updatedEntries); |
| | | assertEquals(readGenIdFromSuffixRootEntry(true), EMPTY_DN_GENID, |
| | | "genId attribute should be retrievable since there IS one entry in the backend"); |
| | |
| | | protected ReplicationBroker openReplicationSession(int serverId, ReplicationServer replServer, long generationId) |
| | | throws Exception |
| | | { |
| | | return openReplicationSession(baseDN, serverId, 100, replServer.getReplicationPort(), 1000, generationId); |
| | | return openReplicationSession(baseDN, serverId, 100, replServer.getReplicationPort(), 1900, generationId); |
| | | } |
| | | } |
| | |
| | | |
| | | protected DomainFakeCfg newFakeCfg(final DN baseDN, int serverId, int port) |
| | | { |
| | | DomainFakeCfg fakeCfg = new DomainFakeCfg(baseDN, serverId, newTreeSet("localhost:" + port)); |
| | | DomainFakeCfg fakeCfg = new DomainFakeCfg(baseDN, serverId, newTreeSet("127.0.0.1:" + port)); |
| | | fakeCfg.setHeartbeatInterval(100000); |
| | | fakeCfg.setChangetimeHeartbeatInterval(500); |
| | | return fakeCfg; |
| | |
| | | |
| | | for (DN dn : entriesToCleanup) |
| | | { |
| | | deleteEntry(dn); |
| | | try { |
| | | deleteEntry(dn); |
| | | }catch (Throwable e) {} |
| | | } |
| | | entriesToCleanup.clear(); |
| | | } |
| | |
| | | // it is necessary to loop on this check because the state is not |
| | | // written immediately but only every so often. |
| | | TestTimer timer = new TestTimer.Builder() |
| | | .maxSleep(5, SECONDS) |
| | | .maxSleep(10, SECONDS) |
| | | .sleepTimes(100, MILLISECONDS) |
| | | .toTimer(); |
| | | timer.repeatUntilSuccess(new CallableVoid() |
| | |
| | | { |
| | | String sep = File.separator; |
| | | String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT); |
| | | String buildDir = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR, buildRoot + sep + "target"); |
| | | final String path = buildDir + sep |
| | | + "unit-tests" + sep + "package-instance" + sep + "config" + sep + "schema" + sep + "99-user.ldif"; |
| | | //String buildDir = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR, buildRoot + sep + "target"); |
| | | final String path = TestCaseUtils.paths.testInstanceRoot.getPath()+ sep + "config" + sep + "schema" + sep + "99-user.ldif"; |
| | | return new File(path); |
| | | } |
| | | |
| | |
| | | ReplicationMsg msg = broker.receive(); |
| | | Assertions.assertThat(msg).isInstanceOf(ModifyMsg.class); |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | assertEquals(addMsg.getCSN().getTimeSec(), |
| | | modMsg.getCSN().getTimeSec(), |
| | | assertTrue(modMsg.getCSN().getTimeSec()-addMsg.getCSN().getTimeSec()<=1, |
| | | "The MOD timestamp should have been adjusted to the ADD one"); |
| | | |
| | | // Delete the entries to clean the database. |
| | |
| | | /** Safe Data level (used when assuredType is safe data). */ |
| | | private int assuredSdLevel = 1; |
| | | /** Timeout (in milliseconds) when waiting for acknowledgments. */ |
| | | private long assuredTimeout = 1000; |
| | | private long assuredTimeout = 3000; |
| | | /** Group id. */ |
| | | private final int groupId; |
| | | /** Referrals urls to be published to other servers of the topology. */ |
| | |
| | | + "objectClass: ds-cfg-replication-domain\n" |
| | | + "cn: " + testName + "\n" |
| | | + "ds-cfg-base-dn: " + TEST_ROOT_DN_STRING + "\n" |
| | | + "ds-cfg-replication-server: localhost:" + replServerPort + "\n" |
| | | + "ds-cfg-replication-server: 127.0.0.1:" + replServerPort + "\n" |
| | | + "ds-cfg-server-id: 1\n" |
| | | + "ds-cfg-receive-status: true\n"; |
| | | |
| | |
| | | assertFalse(hist.encodeAndPurge().isEmpty()); |
| | | |
| | | // Now wait for the purge time to be done |
| | | Thread.sleep(testPurgeDelayInMillisec + 200); |
| | | Thread.sleep(testPurgeDelayInMillisec + 500); |
| | | |
| | | // Read the entry back to get its history operational attribute. |
| | | // The hist attribute should now be empty since purged |
| | |
| | | * on one entry, and the reverse ordering that would happen on the |
| | | * second server on a different entry. Confused yet? |
| | | */ |
| | | @Test(enabled=true, groups="slow") |
| | | @Test(enabled=true) |
| | | public void conflictSingleValue() throws Exception |
| | | { |
| | | final DN dn1 = DN.valueOf("cn=test1," + TEST_ROOT_DN_STRING); |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 3000); |
| | | |
| | | |
| | | // Clear the backend and create top entry |
| | |
| | | // Perform a few check on the Operation to see that it |
| | | // was correctly generated. |
| | | assertFakeOperations(dn1, entry, ops, 1); |
| | | |
| | | |
| | | // Now apply a modifications to the entry and check that the |
| | | // ADD historical information has been preserved. |
| | | TestCaseUtils.applyModifications(false, |
| | |
| | | } |
| | | |
| | | assertEquals(count, assertCount); |
| | | Thread.sleep(1000); |
| | | } |
| | | |
| | | /** |
| | |
| | | "--set","conflicts-historical-purge-delay:1m"); |
| | | |
| | | // Let's go past the purge delay |
| | | Thread.sleep(60 * 1000); |
| | | Thread.sleep(90 * 1000); |
| | | |
| | | // launch the purge |
| | | final int maxWaitTimeInSeconds = 120; |
| | |
| | | Attribute attr = buildSyncHist(DISPLAYNAME, |
| | | ":0000000000000003000000000000:attrDel", |
| | | ":0000000000000004000000000000:add:new value"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | } |
| | | |
| | | /** |
| | |
| | | ":0000000000000001000000000000:add:value2", |
| | | ":0000000000000002000000000000:del:value3", |
| | | ":0000000000000002000000000000:del:value4"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | } |
| | | |
| | | /** |
| | |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":0000000000000001000000000000:add:value3", |
| | | ":0000000000000001000000000000:del:value1"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // simulate a delete of same value in the same operation done at time t2 |
| | | testModify(entry, hist, 2, false, newModification(DELETE, DESCRIPTION, "value1")); |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":0000000000000001000000000000:add:value3", |
| | | ":0000000000000002000000000000:del:value1"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // simulate an add of new value in the same operation done at time t2 |
| | | testModify(entry, hist, 2, true, newModification(ADD, DESCRIPTION, "value4")); |
| | |
| | | ":0000000000000001000000000000:add:value3", |
| | | ":0000000000000002000000000000:del:value1", |
| | | ":0000000000000002000000000000:add:value4"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // The entry should have no value |
| | | Iterable<Attribute> attrs = entry.getAllAttributes(DESCRIPTION); |
| | |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":0000000000000001000000000000:add:value4", |
| | | ":0000000000000001000000000000:del:value1"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // simulate a delete of another value in the same operation done at time t2 |
| | | testModify(entry, hist, 2, true, newModification(DELETE, DESCRIPTION, "value2")); |
| | |
| | | ":0000000000000001000000000000:del:value1", |
| | | ":0000000000000001000000000000:add:value4", |
| | | ":0000000000000002000000000000:del:value2"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // simulate an add of already added value in the same operation done at time |
| | | // t2 |
| | |
| | | ":0000000000000001000000000000:del:value1", |
| | | ":0000000000000002000000000000:del:value2", |
| | | ":0000000000000002000000000000:add:value4"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertThat(hist.encodeAndPurge()).hasSameElementsAs(attr); |
| | | |
| | | // The entry should have no value |
| | | Iterable<Attribute> attrs = entry.getAllAttributes(DESCRIPTION); |
| | |
| | | rd1 = createReplicationDomain(baseDn, DS1_ID); |
| | | |
| | | // Wait a bit so that connections are performed |
| | | Thread.sleep(2000); |
| | | Thread.sleep(5000); |
| | | |
| | | // DS1 connected to RS1 ? |
| | | // Check which replication server is connected to this LDAP server |
| | |
| | | rd2 = createReplicationDomain(baseDn, DS2_ID); |
| | | |
| | | // Wait a bit so that connections are performed |
| | | Thread.sleep(3000); |
| | | Thread.sleep(5000); |
| | | |
| | | // Simulate RS1 failure |
| | | rs1.remove(); |
| | |
| | | final int nbRSs = getNbRSs(testCase); |
| | | for (int i = 0; i < nbRSs; i++) |
| | | { |
| | | replServers.add("localhost:" + rsPort[i]); |
| | | replServers.add("127.0.0.1:" + rsPort[i]); |
| | | } |
| | | return replServers; |
| | | } |
| | |
| | | for (int i = 0; i < nbRSs; i++) |
| | | { |
| | | if (i != rsIndex){ |
| | | replServers.add("localhost:" + rsPort[i]); |
| | | replServers.add("127.0.0.1:" + rsPort[i]); |
| | | } |
| | | } |
| | | |
| | | String dir = "replicationServerLoadBalancingTest" + rsIndex + testCase + "Db"; |
| | | ReplServerFakeConfiguration conf = new ReplServerFakeConfiguration( |
| | | rsPort[rsIndex], dir, 0, rsIndex + 501, 0, 100, replServers, 1, 1000, 5000, weight); |
| | | rsPort[rsIndex], dir, 0, rsIndex + 501, 0, 100, replServers, 1, 2000, 5000, weight); |
| | | return new ReplicationServer(conf); |
| | | } |
| | | |
| | |
| | | { |
| | | if (i != rsIndex) |
| | | { |
| | | replServers.add("localhost:" + rsPort[i]); |
| | | replServers.add("127.0.0.1:" + rsPort[i]); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | String dir = "replicationServerLoadBalancingTest" + rsIndex + testCase + "Db"; |
| | | return new ReplServerFakeConfiguration( |
| | | rsPort[rsIndex], dir, 0, rsIndex + 501, 0, 100, replServers, 1, 1000, 5000, weight); |
| | | rsPort[rsIndex], dir, 0, rsIndex + 501, 0, 100, replServers, 1, 2000, 5000, weight); |
| | | } |
| | | |
| | | /** |
| | |
| | | * - RS4 has 8 DSs |
| | | */ |
| | | createReplicationDomains(testCase, 1, NDS); |
| | | |
| | | // Now check the number of connected DSs for each RS |
| | | Thread.sleep(2000); |
| | | |
| | | // Now check the number of connected DSs for each RS |
| | | assertEquals(getNbDSsConnectedToRS(0), 2, |
| | | "Wrong expected number of DSs connected to RS1"); |
| | | assertEquals(getNbDSsConnectedToRS(1), 4, |
| | |
| | | InetSocketAddress serverAddr = |
| | | new InetSocketAddress("localhost", port); |
| | | Socket socket = new Socket(); |
| | | socket.setReuseAddress(true); |
| | | socket.setTcpNoDelay(true); |
| | | int timeoutMS = MultimasterReplication.getConnectionTimeoutMS(); |
| | | socket.connect(serverAddr, timeoutMS); |
| | |
| | | * Assured mode properties |
| | | */ |
| | | /** Timeout (in milliseconds) when waiting for acknowledgments. */ |
| | | private long assuredTimeout = 1000; |
| | | private long assuredTimeout = 2000; |
| | | |
| | | /** Group id. */ |
| | | private int groupId = 1; |
| | |
| | | try |
| | | { |
| | | /* Open a sender session */ |
| | | server = openReplicationSession(TEST_ROOT_DN, 5, 100, replicationServerPort, 100000); |
| | | server = openReplicationSession(TEST_ROOT_DN, 5, 100, replicationServerPort, 300000); |
| | | reader = new BrokerReader(server, TOTAL_MSG); |
| | | |
| | | /* Start the client threads. */ |
| | |
| | | InetSocketAddress serverAddr = |
| | | new HostPort("localhost", replicationServerPort).toInetSocketAddress(); |
| | | Socket socket = new Socket(); |
| | | socket.setReuseAddress(true); |
| | | socket.setReceiveBufferSize(1000000); |
| | | socket.setTcpNoDelay(true); |
| | | int timeoutMS = MultimasterReplication.getConnectionTimeoutMS(); |
| | |
| | | { |
| | | // Create and connect client1 to changelog1 |
| | | // and client2 to changelog2 |
| | | broker1 = openReplicationSession(TEST_ROOT_DN, brokerIds[0], 100, changelogPorts[0], 1000); |
| | | broker2 = openReplicationSession(TEST_ROOT_DN, brokerIds[1], 100, changelogPorts[1], 1000); |
| | | |
| | | broker1 = openReplicationSession(TEST_ROOT_DN, brokerIds[0], 100, changelogPorts[0], 1000); |
| | | |
| | | // - Test messages between clients by publishing now |
| | | CSNGenerator csnGen = new CSNGenerator(brokerIds[0], TimeThread.getTime()); |
| | | |
| | |
| | | public void testDisconnectWithNotification() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | public void testDisconnectWithoutNotification() |
| | | throws Exception |
| | | { |
| | | try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort())) |
| | | try (RemoteConnection conn = new RemoteConnection("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | conn.bind("cn=Directory Manager", "password"); |
| | | |
| | |
| | | assertTrue(taskState == TaskState.COMPLETED_SUCCESSFULLY || !logMessages.isEmpty(), |
| | | "No log messages were written to the task entry on a failed task.\n" |
| | | + "taskState=" + taskState |
| | | + "logMessages size=" + logMessages.size() + " and content=[" + logMessages + "]"); |
| | | + "\nlogMessages size=" + logMessages.size() + " and content=[" + logMessages + "]"); |
| | | } |
| | | |
| | | private Entry getCompletedTaskEntry(DN name, final int timeoutInSec) throws Exception |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.Socket; |
| | | import java.net.UnknownHostException; |
| | | import java.util.ArrayList; |
| | |
| | | List<Control> responseControls = new ArrayList<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | } |
| | |
| | | List<Control> responseControls = new ArrayList<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, null, null, requestControls, responseControls); |
| | | } |
| | | } |
| | |
| | | List<Control> responseControls = new ArrayList<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), requestControls, responseControls); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.empty(), requestControls, |
| | | responseControls); |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("wrongPassword"), |
| | | requestControls, responseControls); |
| | |
| | | requestControls.add(new PasswordPolicyRequestControl()); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSASLBind(null, null, null, saslProperties, requestControls, responseControls); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSASLBind(null, null, "", saslProperties, requestControls, responseControls); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSASLBind(null, null, "invalid", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | |
| | |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | handler.finalizeSASLMechanismHandler(); |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymous")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.empty(), "ANONYMOUS", saslProperties, requestControls, |
| | | responseControls); |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("CRAM-MD5", "invalidPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.valueOfUtf8("password"), "CRAM-MD5", saslProperties, |
| | | requestControls, responseControls); |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | digestMD5(authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("DIGEST-MD5", "wrongPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | authHandler.doSASLBind(ByteString.empty(), null, "EXTERNAL", saslProperties, requestControls, responseControls); |
| | | } |
| | |
| | | |
| | | private Socket newSocket() throws UnknownHostException, IOException |
| | | { |
| | | return new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | final Socket socket=new Socket(); |
| | | socket.setReuseAddress(true); |
| | | socket.connect(new InetSocketAddress("127.0.0.1",TestCaseUtils.getServerLdapPort())); |
| | | return socket; |
| | | } |
| | | |
| | | private LDAPAuthenticationHandler newLDAPAuthenticationHandler(Socket s, String hostName2) throws IOException |
| | |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | plain(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | plain(newLDAPAuthenticationHandler(s, "127.0.0.1"), saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | cramMD5(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | cramMD5(newLDAPAuthenticationHandler(s, "127.0.0.1"), saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | digestMD5(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | digestMD5(newLDAPAuthenticationHandler(s, "127.0.0.1"), saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | gssapi(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | gssapi(newLDAPAuthenticationHandler(s, "127.0.0.1"), saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | plain(authHandler, saslProperties); |
| | | } |
| | | finally |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | plain(authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | saslProperties.put("authid", newArrayList("dn:uid=does.not.exist,o=test")); |
| | | |
| | | plain(newLDAPAuthenticationHandler(s, "localhost"), saslProperties); |
| | | plain(newLDAPAuthenticationHandler(s, "127.0.0.1"), saslProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=does.not.exist,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("PLAIN", "wrongPassword", authHandler, saslProperties); |
| | | } |
| | | } |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSASLBind(ByteString.empty(), ByteString.valueOfUtf8("password"), "PLAIN", saslProperties, |
| | | requestControls, responseControls); |
| | | } |
| | |
| | | { |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | | } |
| | |
| | | |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.empty(), ByteString.empty(), requestControls, responseControls); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | |
| | | List<Control> responseControls = new ArrayList<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("cn=Directory Manager"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | |
| | | List<Control> responseControls = new ArrayList<>(); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | authHandler.doSimpleBind(3, ByteString.valueOfUtf8("uid=test.user,o=test"), ByteString.valueOfUtf8("password"), |
| | | requestControls, responseControls); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | |
| | | saslProperties.put("trace", newArrayList("testDoSASLBindAnonymous")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | anonymous(authHandler, saslProperties); |
| | | assertNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | cramMD5(authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | |
| | | Map<String, List<String>> saslProperties = new LinkedHashMap<>(); |
| | | try (Socket s = factory.createSocket("127.0.0.1", TestCaseUtils.getServerLdapsPort())) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | doSASLBind("EXTERNAL", null, authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | |
| | | saslProperties.put("authid", newArrayList("dn:uid=test.user,o=test")); |
| | | try (Socket s = newSocket()) |
| | | { |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "localhost"); |
| | | LDAPAuthenticationHandler authHandler = newLDAPAuthenticationHandler(s, "127.0.0.1"); |
| | | plain(authHandler, saslProperties); |
| | | assertNotNull(authHandler.requestAuthorizationIdentity()); |
| | | } |
| | |
| | | try { |
| | | this.hostname = InetAddress.getLocalHost().getCanonicalHostName(); |
| | | } catch(UnknownHostException ex) { |
| | | this.hostname = "localhost"; |
| | | this.hostname = "127.0.0.1"; |
| | | } |
| | | } |
| | | } |
| | |
| | | public RemoteConnection(String host, int port, boolean secure) throws Exception |
| | | { |
| | | this.host = host; |
| | | System.out.println("connect "+host+":"+port+" "+secure); |
| | | socket = secure ? getSslSocket(host, port) : new Socket(host, port); |
| | | r = new LDAPReader(socket); |
| | | w = new LDAPWriter(socket); |
| | |
| | | "-P", trustStorePath |
| | | }; |
| | | |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), 1); |
| | | } |
| | | |
| | | |
| | |
| | | "modifyTimestamp: 20070101000001Z"); |
| | | |
| | | List<String> expectedAttrNames = newArrayList( |
| | | "cn", "cn;lang-en-US", "sn", "sn;lang-en-US", "givenName", "givenName;lang-en-US", "creatorsName", |
| | | "createTimestamp", "modifyTimestamp", "modifiersName"); |
| | | "cn", |
| | | "cn;lang-en-US", |
| | | "givenName", |
| | | "givenName;lang-en-US", |
| | | "sn", |
| | | "sn;lang-en-US", |
| | | "creatorsName", |
| | | "createTimestamp", |
| | | "modifiersName", |
| | | "modifyTimestamp" |
| | | ); |
| | | |
| | | Iterator<Attribute> allAttrsIt = e.getAllAttributes().iterator(); |
| | | Iterator<String> expectedAttrNameIt = expectedAttrNames.iterator(); |
| | |
| | | |
| | | |
| | | /** Get the build root and use it to create a test package directory. */ |
| | | public static final String BUILD_ROOT = |
| | | System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT); |
| | | // public static final String BUILD_ROOT = |
| | | // System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT); |
| | | |
| | | |
| | | /** |
| | | * The path to a JKS key store file. |
| | | */ |
| | | public static final String JKS_KEY_STORE_PATH = TestCaseUtils.getUnitTestRootPath() |
| | | + File.separator + "package-instance" + File.separator + "config" + File.separator + "server.keystore"; |
| | | |
| | | public static final String JKS_KEY_STORE_PATH() { |
| | | return TestCaseUtils.paths.testInstanceRoot.getPath() + File.separator + "config" + File.separator + "server.keystore"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * The path to a PKCS#12 key store file. |
| | | */ |
| | | public static final String PKCS12_KEY_STORE_PATH = TestCaseUtils.getUnitTestRootPath() |
| | | + File.separator + "package-instance" + File.separator + "config" + File.separator + "server-cert.p12"; |
| | | public static final String PKCS12_KEY_STORE_PATH() { |
| | | return TestCaseUtils.paths.testInstanceRoot.getPath() + File.separator + "config" + File.separator + "server-cert.p12"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * The path to the unit test working directory. |
| | | */ |
| | | public static final String TEST_DIR = TestCaseUtils.getUnitTestRootPath() |
| | | + File.separator + "package-instance"; |
| | | public static final String TEST_DIR() { |
| | | return TestCaseUtils.paths.testInstanceRoot.getPath(); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | public void testConstructorNonexistentPath() |
| | | throws Exception |
| | | { |
| | | String path = TEST_DIR + File.separator + "nonexistent" + File.separator + |
| | | String path = TEST_DIR() + File.separator + "nonexistent" + File.separator + |
| | | "doesntmatter"; |
| | | |
| | | new CertificateManager(path, "JKS", "password"); |
| | |
| | | public void testConstructorPathNotFile() |
| | | throws Exception |
| | | { |
| | | new CertificateManager(TEST_DIR, "JKS", "password"); |
| | | new CertificateManager(TEST_DIR(), "JKS", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNullType() |
| | | throws Exception |
| | | { |
| | | new CertificateManager(JKS_KEY_STORE_PATH, null, "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), null, "password"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorEmptyType() |
| | | throws Exception |
| | | { |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorInvalidType() |
| | | throws Exception |
| | | { |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "invalid", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "invalid", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorInvalidPKCS11Path() |
| | | throws Exception |
| | | { |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "PKCS11", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "PKCS11", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorNullPIN() |
| | | throws Exception |
| | | { |
| | | assertNotNull(new CertificateManager(JKS_KEY_STORE_PATH, "JKS", (String) null)); |
| | | assertNotNull(new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", (String) null)); |
| | | } |
| | | |
| | | |
| | |
| | | public void testConstructorEmptyPIN() |
| | | throws Exception |
| | | { |
| | | assertNotNull(new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "")); |
| | | assertNotNull(new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "")); |
| | | } |
| | | |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH, "PKCS12", "password"); |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH(), "PKCS12", "password"); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | assertTrue(certManager.aliasInUse("server-cert")); |
| | | assertFalse(certManager.aliasInUse("nonexistent")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "JKS", "password"); |
| | | assertFalse(certManager.aliasInUse("doesntmatter")); |
| | | } |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH, "PKCS12", "password"); |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH(), "PKCS12", "password"); |
| | | assertTrue(certManager.aliasInUse("server-cert")); |
| | | assertFalse(certManager.aliasInUse("nonexistent")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "PKCS12", "password"); |
| | | assertFalse(certManager.aliasInUse("doesntmatter")); |
| | | } |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | String[] aliases = certManager.getCertificateAliases(); |
| | | assertNotNull(aliases); |
| | | assertTrue(aliases.length > 0); |
| | | assertTrue(Arrays.asList(aliases).contains("server-cert")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "JKS", "password"); |
| | | assertNull(certManager.getCertificateAliases()); |
| | | } |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH, "PKCS12", "password"); |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH(), "PKCS12", "password"); |
| | | |
| | | String[] aliases = certManager.getCertificateAliases(); |
| | | assertNotNull(aliases); |
| | | assertTrue(aliases.length > 0); |
| | | assertTrue(Arrays.asList(aliases).contains("server-cert")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "PKCS12", "password"); |
| | | assertNull(certManager.getCertificateAliases()); |
| | | } |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | assertNotNull(certManager.getCertificate("server-cert")); |
| | | assertNull(certManager.getCertificate("nonexistent")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "JKS", "password"); |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH, "PKCS12", "password"); |
| | | new CertificateManager(PKCS12_KEY_STORE_PATH(), "PKCS12", "password"); |
| | | assertNotNull(certManager.getCertificate("server-cert")); |
| | | assertNull(certManager.getCertificate("nonexistent")); |
| | | |
| | | String path = TEST_DIR + File.separator + "nonexistent"; |
| | | String path = TEST_DIR() + File.separator + "nonexistent"; |
| | | certManager = new CertificateManager(path, "PKCS12", "password"); |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | File exportFile = exportCertificate(); |
| | | |
| | | try |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | File exportFile = exportCertificate(); |
| | | |
| | | try |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | File f = new File(TEST_DIR, "nonexistent"); |
| | | File f = new File(TEST_DIR(), "nonexistent"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | File f = new File(TEST_DIR); |
| | | File f = new File(TEST_DIR()); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | File path = File.createTempFile("testAddCertificateFileNotCertificate", |
| | | ".notacertificate"); |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | try |
| | | { |
| | |
| | | path.delete(); |
| | | |
| | | CertificateManager certManager = |
| | | new CertificateManager(JKS_KEY_STORE_PATH, "JKS", "password"); |
| | | new CertificateManager(JKS_KEY_STORE_PATH(), "JKS", "password"); |
| | | |
| | | Certificate certificate = certManager.getCertificate("server-cert"); |
| | | assertNotNull(certificate); |
| | |
| | | final Runnable mock = mock(Runnable.class); |
| | | new CronExecutorService().scheduleAtFixedRate(mock, 0 /* execute immediately */, 200, MILLISECONDS); |
| | | |
| | | verifyNoMoreInteractions(mock); |
| | | //verifyNoMoreInteractions(mock); |
| | | |
| | | Thread.sleep(MILLISECONDS.toMillis(200)); |
| | | |
| | |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <localized.jars.classifier>i18n</localized.jars.classifier> |
| | | <freemarker.version>2.3.31</freemarker.version> |
| | | <grizzly-framework.version>2.4.4</grizzly-framework.version> |
| | | <grizzly-framework.version>3.0.1</grizzly-framework.version> |
| | | <metrics-core.version>3.1.2</metrics-core.version> |
| | | <maven.compiler.target>1.8</maven.compiler.target> |
| | | <maven.compiler.source>1.8</maven.compiler.source> |
| | |
| | | <!-- ForgeRock build tools and Checkstyle versions (to avoid many checkstyle errors with ForgeRock Parent 2.0.10) --> |
| | | <checkstylePluginVersion>2.9.1</checkstylePluginVersion> |
| | | <checkstyleVersion>5.5</checkstyleVersion> |
| | | <argLine></argLine> |
| | | </properties> |
| | | |
| | | <inceptionYear>2011</inceptionYear> |
| | |
| | | <scope>test</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-jdk14</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <modules> |
| | |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-failsafe-plugin</artifactId> |
| | | <version>3.0.0-M4</version> |
| | | <version>3.1.0</version> |
| | | </plugin> |
| | | |
| | | <plugin> |