Skip to content

Commit

Permalink
Run authentication integration tests in enterprise
Browse files Browse the repository at this point in the history
Support the Bolt and REST authentication integration tests on enterprise
server with enterprise auth manager
  • Loading branch information
henriknyman committed May 31, 2016
1 parent 69b338b commit bd22f98
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 12 deletions.
Expand Up @@ -28,13 +28,16 @@

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;

import org.neo4j.bolt.v1.transport.socket.client.Connection;
import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection;
import org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection;
import org.neo4j.bolt.v1.transport.socket.client.SocketConnection;
import org.neo4j.bolt.v1.transport.socket.client.WebSocketConnection;
import org.neo4j.function.Factory;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.HostnamePort;
import org.neo4j.kernel.api.exceptions.Status;
Expand All @@ -53,8 +56,12 @@
public class AuthenticationIT
{
@Rule
public Neo4jWithSocket server = new Neo4jWithSocket( settings ->
settings.put( GraphDatabaseSettings.auth_enabled, "true" ) );
public Neo4jWithSocket server = new Neo4jWithSocket( getSettingsFunction() );

protected Consumer<Map<Setting<?>, String>> getSettingsFunction()
{
return settings -> settings.put( GraphDatabaseSettings.auth_enabled, "true" );
}

@Parameterized.Parameter( 0 )
public Factory<Connection> cf;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class AuthenticationDocIT extends ExclusiveServerTestBase
{
@Rule
public TestData<RESTDocsGenerator> gen = TestData.producedThrough( RESTDocsGenerator.PRODUCER );
private CommunityNeoServer server;
protected CommunityNeoServer server;

@Before
public void setUp()
Expand Down Expand Up @@ -189,7 +189,7 @@ public void shouldSayMalformedHeaderIfMalformedAuthorization() throws Exception
}

@Test
public void shouldNotAllowDataAccess() throws Exception
public void shouldAllowDataAccess() throws Exception
{
// Given
startServerWithConfiguredUser();
Expand Down
32 changes: 32 additions & 0 deletions enterprise/security/pom.xml
Expand Up @@ -103,6 +103,33 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-bolt</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-bolt</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-io</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -148,6 +175,11 @@
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Expand Up @@ -189,8 +189,6 @@ public void setPassword( AuthSubject authSubject, String username, String passwo
throw new AuthorizationViolationException( "Invalid attempt to change the password for user " + username );
}

passwordPolicy.validatePassword( password );

setUserPassword( username, password );
}

Expand Down
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.server.security.enterprise.auth.integration.bolt;

import java.util.Map;
import java.util.function.Consumer;

import org.neo4j.bolt.v1.transport.integration.AuthenticationIT;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;

public class EnterpriseAuthenticationIT extends AuthenticationIT
{
@Override
protected Consumer<Map<Setting<?>, String>> getSettingsFunction()
{
return settings -> {
settings.put( GraphDatabaseSettings.auth_enabled, "true" );
settings.put( GraphDatabaseSettings.auth_manager, "enterprise-auth-manager" );
};
}
}
3 changes: 0 additions & 3 deletions enterprise/server-enterprise/LICENSES.txt
Expand Up @@ -5,16 +5,13 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
Apache Software License, Version 2.0
Apache Commons Configuration
Apache Commons Lang
Apache Shiro :: Core
Apache Shiro :: Support :: EHCache
Commons BeanUtils
Commons Digester
Commons IO
Commons Lang
Commons Logging
ConcurrentLinkedHashMap
Data Mapper for Jackson
Ehcache Core
Graphite Integration for Metrics
hazelcast-all
Jackson
Expand Down
3 changes: 0 additions & 3 deletions enterprise/server-enterprise/NOTICE.txt
Expand Up @@ -27,16 +27,13 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Configuration
Apache Commons Lang
Apache Shiro :: Core
Apache Shiro :: Support :: EHCache
Commons BeanUtils
Commons Digester
Commons IO
Commons Lang
Commons Logging
ConcurrentLinkedHashMap
Data Mapper for Jackson
Ehcache Core
Graphite Integration for Metrics
hazelcast-all
Jackson
Expand Down
13 changes: 13 additions & 0 deletions enterprise/server-enterprise/pom.xml
Expand Up @@ -109,6 +109,19 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-security-enterprise</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-security-enterprise</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.neo4j</groupId>
Expand Down
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.server.rest.security;

import java.io.IOException;

import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.server.enterprise.helpers.EnterpriseServerBuilder;

public class EnterpriseAuthenticationDocIT extends AuthenticationDocIT
{
@Override
public void startServer( boolean authEnabled ) throws IOException
{
server = EnterpriseServerBuilder.server()
.withProperty( GraphDatabaseSettings.auth_enabled.name(), Boolean.toString( authEnabled ) )
.withProperty( GraphDatabaseSettings.auth_manager.name(), "enterprise-auth-manager" )
.build();
server.start();
}
}

0 comments on commit bd22f98

Please sign in to comment.