mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
yesterday 10fc27e672753c6718197cf36da388a5d66bd285
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions copyright [year] [name of copyright owner]".
 *
 * Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.util;
 
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
 
import java.util.Arrays;
 
import org.opends.server.DirectoryServerTestCase;
import org.testng.annotations.Test;
 
/**
 * Pins the flag that keeps bc-fips from seeding its DRBG from the CPU's RDSEED instruction in the
 * test JVMs and in the JVMs they start from the built package, see issue #1161.
 */
@SuppressWarnings("javadoc")
public class BcFipsNativeLibrariesOffTest extends DirectoryServerTestCase
{
  private static final String FLAG = "-Dorg.bouncycastle.native.cpu_variant=java";
 
  @Test
  public void theTestJvmRunsWithoutTheNativeLibraries()
  {
    assertEquals(System.getProperty("org.bouncycastle.native.cpu_variant"), "java",
        "the test JVM lost the bc-fips cpu_variant flag, see #1161");
  }
 
  /** setup, and start-ds through ServerController, inherit the environment of the failsafe fork. */
  @Test
  public void theJvmsStartedFromThePackageInheritTheFlag()
  {
    final String toolOptions = System.getenv("JAVA_TOOL_OPTIONS");
    assertNotNull(toolOptions, "the failsafe fork lost JAVA_TOOL_OPTIONS, see #1161");
    assertTrue(Arrays.asList(toolOptions.trim().split("\\s+")).contains(FLAG),
        "JAVA_TOOL_OPTIONS of the failsafe fork lost the bc-fips cpu_variant flag, see #1161: " + toolOptions);
  }
}