Skip to content

Commit

Permalink
Merge branch 'jennyowen/authentication-weirdness'
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyowen committed Nov 1, 2022
2 parents d11fc55 + 152a26f commit 4eada83
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
19 changes: 11 additions & 8 deletions docker-image-src/5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function install_neo4j_labs_plugins
local _old_config="$(mktemp)"
cp "${NEO4J_HOME}"/conf/neo4j.conf "${_old_config}"
for plugin_name in $(echo "${NEO4J_PLUGINS}" | jq --raw-output '.[]'); do
debug_msg "Plugin ${plugin_name} will be installed"
local _location="$(jq --raw-output "with_entries( select(.key==\"${plugin_name}\") ) | to_entries[] | .value.location" /startup/neo4jlabs-plugins.json )"
if [ "${_location}" != "null" -a -n "$(shopt -s nullglob; echo ${_location})" ]; then
debug_msg "$plugin_name is already in the container at ${_location}"
Expand Down Expand Up @@ -333,7 +334,7 @@ function set_initial_password
debug_msg "${neo4j_admin_cmd} dbms set-initial-password ${password} ${extra_args[*]}"
if debugging_enabled; then
# don't suppress any output or errors in debugging mode
${neo4j_admin_cmd} dbms set-initial-password "${password}" "${extra_args[@]}"
${neo4j_admin_cmd} dbms set-initial-password "${password}" "${extra_args[@]}" --verbose
else
# Will exit with error if users already exist (and print a message explaining that)
# we probably don't want the message though, since it throws an error message on restarting the container.
Expand Down Expand Up @@ -495,6 +496,14 @@ if [ -d /licenses ]; then
: ${NEO4J_server_directories_licenses:="/licenses"}
fi


# ==== LOAD PLUGINS ====

if [[ ! -z "${NEO4J_PLUGINS:-}" ]]; then
# NEO4J_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc", "streams", "graphql"]'
install_neo4j_labs_plugins
fi

# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ====

# Env variable naming convention:
Expand Down Expand Up @@ -560,16 +569,10 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do
fi
done

# ==== SET PASSWORD AND PLUGINS ====
# ==== SET PASSWORD ====

set_initial_password "${NEO4J_AUTH:-}"


if [[ ! -z "${NEO4J_PLUGINS:-}" ]]; then
# NEO4J_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc", "streams", "graphql"]'
install_neo4j_labs_plugins
fi

# ==== INVOKE NEO4J STARTUP ====

[ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT}
Expand Down
2 changes: 1 addition & 1 deletion docker-image-src/5/neo4jlabs-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"location": "/var/lib/neo4j/products/bloom-plugin-*.jar",
"versions": "https://bloom-plugins.s3.eu-west-2.amazonaws.com/versions.json",
"properties": {
"dbms.unmanaged_extension_classes": "com.neo4j.bloom.server=/browser/bloom",
"server.unmanaged_extension_classes": "com.neo4j.bloom.server=/browser/bloom",
"dbms.security.procedures.unrestricted": "bloom.*",
"dbms.bloom.license_file": "/licenses/bloom.license"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.neo4j.docker.neo4jserver.plugins;

import com.neo4j.docker.utils.DatabaseIO;
import com.neo4j.docker.utils.HostFileSystemOperations;
import com.neo4j.docker.utils.Neo4jVersion;
import com.neo4j.docker.utils.TestSettings;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -28,17 +30,20 @@ public class TestBundledPluginInstallation
private static final int DEFAULT_BROWSER_PORT = 7474;
private static final int DEFAULT_BOLT_PORT = 7687;
private static final Logger log = LoggerFactory.getLogger( TestBundledPluginInstallation.class );
private static String APOC = "apoc";
private static String APOC_CORE = "apoc-core";
private static String BLOOM = "bloom";
private static String GDS = "graph-data-science";


static Stream<Arguments> bundledPluginsArgs() {
return Stream.of(
// plugin name key, version it's bundled since, is enterprise only
Arguments.arguments( "apoc-core", new Neo4jVersion(4, 3, 15), new Neo4jVersion(5, 0, 0), false ),
Arguments.arguments( "apoc", new Neo4jVersion(5, 0, 0), null, false ),
//todo reenable this when gds is back in 5.0
// plugin name key, version it's bundled since, version bundled until, is enterprise only
Arguments.arguments( APOC_CORE, new Neo4jVersion(4, 3, 15), new Neo4jVersion(5, 0, 0), false ),
Arguments.arguments( APOC, new Neo4jVersion(5, 0, 0), null, false ),
//https://trello.com/c/hE5D6LwB/913-in-testbundledplugininstallation-re-enable-gds-test-once-it-is-packaged-back-into-50
//Arguments.arguments( "graph-data-science", new Neo4jVersion( 4,4,0 ), null, true ),
Arguments.arguments( "bloom", new Neo4jVersion( 4,4,0 ), null, true )
Arguments.arguments( GDS, new Neo4jVersion( 4,4,0 ), null, true ),
Arguments.arguments( BLOOM, new Neo4jVersion( 4,4,0 ), null, true )
);
}

Expand Down Expand Up @@ -84,6 +89,8 @@ public void testBundledPlugin(String pluginName, Neo4jVersion bundledSince, Neo4
"bundled-"+pluginName+"-plugin-",
"/plugins" );
container.start();
DatabaseIO dbio = new DatabaseIO( container );
dbio.putInitialDataIntoContainer( "neo4j", "none" );
}
catch(ContainerLaunchException e)
{
Expand All @@ -109,10 +116,6 @@ public void testBundledPlugin(String pluginName, Neo4jVersion bundledSince, Neo4
Stream.of(logs.split( "\n" ))
.anyMatch( line -> line.matches( "Installing Plugin '" + pluginName + "' from /var/lib/neo4j/.*" ) ),
"Plugin was not installed from neo4j home");
// Assertions.assertFalse(
// Stream.of(errlogs.split( "\n" ))
// .anyMatch( line -> line.matches( "Failed to read config .+: Unrecognized setting\\..*" ) ),
// "An invalid configuration setting was set");
}
if(container !=null)
{
Expand Down Expand Up @@ -176,10 +179,6 @@ public void testBundledPlugin(String pluginName, Neo4jVersion bundledSince, Neo4
Stream.of(logs.split( "\n" ))
.anyMatch( line -> line.matches( "Fetching versions.json for Plugin '" + pluginName + "' from http[s]?://.*" ) ),
"Plugin was not installed from cloud");
// Assertions.assertFalse(
// Stream.of(errlogs.split( "\n" ))
// .anyMatch( line -> line.matches( "Failed to read config .+: Unrecognized setting\\..*" ) ),
// "An invalid configuration setting was set");
}
if(container !=null)
{
Expand All @@ -191,4 +190,26 @@ public void testBundledPlugin(String pluginName, Neo4jVersion bundledSince, Neo4
}
}
}

@Test
void testPluginLoadsWithAuthentication() throws Exception
{
Assumptions.assumeTrue( TestSettings.NEO4J_VERSION.isAtLeastVersion( Neo4jVersion.NEO4J_VERSION_500 ) );

final String PASSWORD = "12345";
Path testFolder = HostFileSystemOperations.createTempFolder( "plugin-with-auth-loads" );

try( GenericContainer container = createContainerWithBundledPlugin(BLOOM))
{
container.withEnv( "NEO4J_AUTH", "neo4j/"+PASSWORD )
.withEnv( "NEO4J_dbms_bloom_license__file", "/licenses/bloom.license" );
// mounting logs because it's useful for debugging
HostFileSystemOperations.createTempFolderAndMountAsVolume( container, "logs", "/logs", testFolder );

// make sure the container successfully starts and we can write to it without getting authentication errors
container.start();
DatabaseIO dbio = new DatabaseIO( container );
dbio.putInitialDataIntoContainer( "neo4j", PASSWORD );
}
}
}

0 comments on commit 4eada83

Please sign in to comment.