Refine search
@Test public void shouldSetSecretParameter() { // Given Config config = Config.builder() .withSetting( MySettingsWithDefaults.password, "this should not be visible" ) .withSetting( MySettingsWithDefaults.hello, "ABC" ) .withConfigClasses( Arrays.asList( mySettingsWithDefaults, myMigratingSettings ) ) .build(); // Then assertTrue( config.getConfigValues().get( MySettingsWithDefaults.password.name() ).secret() ); assertFalse( config.getConfigValues().get( MySettingsWithDefaults.hello.name() ).secret() ); String configText = config.toString(); assertTrue( configText.contains( Secret.OBSFUCATED ) ); assertFalse( configText.contains( "this should not be visible" ) ); assertFalse( configText.contains( config.get( MySettingsWithDefaults.password ) ) ); }
@Test public void overrideDefaultValuesForCurrentFormat() { Config config = Config.defaults(); int testHeaderSize = 17; ResizableRecordFormats recordFormats = new ResizableRecordFormats( testHeaderSize ); new RecordFormatPropertyConfigurator( recordFormats, config ).configure(); assertEquals( DEFAULT_BLOCK_SIZE - testHeaderSize, config.get( string_block_size ).intValue() ); assertEquals( DEFAULT_BLOCK_SIZE - testHeaderSize, config.get( array_block_size ).intValue() ); assertEquals( DEFAULT_LABEL_BLOCK_SIZE - testHeaderSize, config.get( label_block_size ).intValue() ); }
@Test public void shouldBeAbleToAugmentConfig() { // Given Config config = Config(); // When config.augment( MySettingsWithDefaults.boolSetting, Settings.FALSE ); config.augment( MySettingsWithDefaults.hello, "Bye" ); // Then assertThat( config.get( MySettingsWithDefaults.boolSetting ), equalTo( false ) ); assertThat( config.get( MySettingsWithDefaults.hello ), equalTo( "Bye" ) ); }
@Test public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception { // given DatabaseLayout databaseLayout = testDirectory.databaseLayout(); String[] args = {databaseLayout.databaseDirectory().getAbsolutePath()}; ConsistencyCheckService service = mock( ConsistencyCheckService.class ); // when runConsistencyCheckToolWith( service, args ); // then ArgumentCaptor<Config> config = ArgumentCaptor.forClass( Config.class ); verify( service ).runFullConsistencyCheck( eq( databaseLayout ), config.capture(), any( ProgressMonitorFactory.class ), any( LogProvider.class ), any( FileSystemAbstraction.class ), anyBoolean(), any( ConsistencyFlags.class ) ); assertFalse( config.getValue().get( ConsistencyCheckSettings.consistency_check_property_owners ) ); }
@Test public void passesOnConfigurationIfProvided() throws Exception { // given DatabaseLayout databaseLayout = testDirectory.databaseLayout(); File configFile = testDirectory.file( Config.DEFAULT_CONFIG_FILE_NAME ); Properties properties = new Properties(); properties.setProperty( ConsistencyCheckSettings.consistency_check_property_owners.name(), "true" ); properties.store( new FileWriter( configFile ), null ); String[] args = {databaseLayout.databaseDirectory().getAbsolutePath(), "-config", configFile.getPath()}; ConsistencyCheckService service = mock( ConsistencyCheckService.class ); // when runConsistencyCheckToolWith( service, args ); // then ArgumentCaptor<Config> config = ArgumentCaptor.forClass( Config.class ); verify( service ).runFullConsistencyCheck( eq( databaseLayout ), config.capture(), any( ProgressMonitorFactory.class ), any( LogProvider.class ), any( FileSystemAbstraction.class ), anyBoolean(), any(ConsistencyFlags.class) ); assertTrue( config.getValue().get( ConsistencyCheckSettings.consistency_check_property_owners ) ); }
@SuppressWarnings( "unchecked" ) @Test public void shouldRegisterAtRootByDefault() throws Exception { WebServer webServer = mock( WebServer.class ); Config config = mock( Config.class ); CommunityNeoServer neoServer = mock( CommunityNeoServer.class ); when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) ); when( neoServer.getWebServer() ).thenReturn( webServer ); when( config.get( GraphDatabaseSettings.auth_enabled ) ).thenReturn( true ); DBMSModule module = new DBMSModule( webServer, config, () -> new DiscoverableURIs.Builder().build() ); module.start(); verify( webServer ).addJAXRSClasses( anyList(), anyString(), isNull() ); }
@Test public void keepUserDefinedFormatConfig() { Config config = Config.defaults( string_block_size, "36" ); RecordFormats recordFormats = Standard.LATEST_RECORD_FORMATS; new RecordFormatPropertyConfigurator( recordFormats, config ).configure(); assertEquals( "Should keep used specified value", 36, config.get( string_block_size ).intValue() ); }
@Test public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception { // Given WebServer webServer = mock( WebServer.class ); CommunityNeoServer neoServer = mock( CommunityNeoServer.class ); when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) ); when( neoServer.getWebServer() ).thenReturn( webServer ); Database database = mock( Database.class ); when( neoServer.getDatabase() ).thenReturn( database ); Config config = mock( Config.class ); List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<>(); String path = "/third/party/package"; jaxRsPackages.add( new ThirdPartyJaxRsPackage( "org.example.neo4j", path ) ); when( config.get( ServerSettings.third_party_packages ) ).thenReturn( jaxRsPackages ); // When ThirdPartyJAXRSModule module = new ThirdPartyJAXRSModule( webServer, config, NullLogProvider.getInstance(), neoServer ); module.start(); // Then verify( webServer ).addJAXRSPackages( any( List.class ), anyString(), anyCollection() ); } }
@Test public void shouldAcquireSchemaWriteLockBeforeCreatingUniquenessConstraint() throws Exception { // given String defaultProvider = Config.defaults().get( default_schema_provider ); when( constraintIndexCreator.createUniquenessConstraintIndex( transaction, descriptor, defaultProvider ) ).thenReturn( 42L ); when( storageReader.constraintsGetForSchema( descriptor.schema() ) ).thenReturn( Collections.emptyIterator() ); // when operations.uniquePropertyConstraintCreate( descriptor ); // then order.verify( locks ).acquireExclusive( LockTracer.NONE, ResourceTypes.LABEL, descriptor.getLabelId() ); order.verify( txState ).constraintDoAdd( ConstraintDescriptorFactory.uniqueForSchema( descriptor ), 42L ); }
@Test public void shouldFindPolicyDefaults() File privateKeyFromConfig = config.get( policyConfig.private_key ); File publicCertificateFromConfig = config.get( policyConfig.public_certificate ); File trustedDirFromConfig = config.get( policyConfig.trusted_dir ); File revokedDirFromConfig = config.get( policyConfig.revoked_dir ); String privateKeyPassword = config.get( policyConfig.private_key_password ); boolean allowKeyGeneration = config.get( policyConfig.allow_key_generation ); boolean trustAll = config.get( policyConfig.trust_all ); List<String> tlsVersions = config.get( policyConfig.tls_versions ); List<String> ciphers = config.get( policyConfig.ciphers ); ClientAuth clientAuth = config.get( policyConfig.client_auth );
@Test public void shouldFindThirdPartyJaxRsPackages() throws IOException { // given File file = ServerTestUtils.createTempConfigFile( folder.getRoot() ); try ( BufferedWriter out = new BufferedWriter( new FileWriter( file, true ) ) ) { out.write( ServerSettings.third_party_packages.name() ); out.write( "=" ); out.write( "com.foo.bar=\"mount/point/foo\"," ); out.write( "com.foo.baz=\"/bar\"," ); out.write( "com.foo.foobarbaz=\"/\"" ); out.write( System.lineSeparator() ); } // when Config config = Config.fromFile( file ).withHome( folder.getRoot() ).build(); // then List<ThirdPartyJaxRsPackage> thirdpartyJaxRsPackages = config.get( ServerSettings.third_party_packages ); assertNotNull( thirdpartyJaxRsPackages ); assertEquals( 3, thirdpartyJaxRsPackages.size() ); }
@Test public void shouldUseWorkingDirForHomeDirIfUnspecified() { // given File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build(); // when Config testConf = Config.fromFile( configFile ).build(); // then assertEquals( new File( System.getProperty("user.dir") ), testConf.get( GraphDatabaseSettings.neo4j_home ) ); }
@Test public void augmentAnotherConfig() { Config config = Config(); config.augment( MySettingsWithDefaults.hello, "Hi" ); Config anotherConfig = Config(); anotherConfig.augment( stringMap( MySettingsWithDefaults.boolSetting.name(), Settings.FALSE, MySettingsWithDefaults.hello.name(), "Bye" ) ); config.augment( anotherConfig ); assertThat( config.get( MySettingsWithDefaults.boolSetting ), equalTo( false ) ); assertThat( config.get( MySettingsWithDefaults.hello ), equalTo( "Bye" ) ); }
@Test public void shouldBeDisabledByConfigurationProperty() { assertFalse( configuration.with( udc_enabled, falseVariation ) .withSystemProperty( udc_enabled.name(), DEFAULT ) .withSystemProperty( UDC_DISABLE, DEFAULT ) .config( settingsClasses ).get( udc_enabled ) ); assertFalse( Config.defaults( singletonMap( udc_enabled.name(), "false" ) ).get( udc_enabled ) ); }