-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed issue on copy database in case of database open without authent…
- Loading branch information
Showing
8 changed files
with
161 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
server/src/test/java/com/orientechnologies/orient/server/OServerDatabaseOperationsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.orientechnologies.orient.server; | ||
|
||
import com.orientechnologies.common.io.OIOUtils; | ||
import com.orientechnologies.common.log.OLogManager; | ||
import com.orientechnologies.orient.core.config.OGlobalConfiguration; | ||
import com.orientechnologies.orient.core.db.ODatabaseSession; | ||
import com.orientechnologies.orient.core.db.ODatabaseType; | ||
import com.orientechnologies.orient.core.db.OrientDBConfig; | ||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
import com.orientechnologies.orient.server.config.*; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import javax.management.InstanceAlreadyExistsException; | ||
import javax.management.MBeanRegistrationException; | ||
import javax.management.MalformedObjectNameException; | ||
import javax.management.NotCompliantMBeanException; | ||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.ArrayList; | ||
import java.util.logging.Level; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class OServerDatabaseOperationsTest { | ||
|
||
private OServer server; | ||
|
||
@Before | ||
public void before() | ||
throws ClassNotFoundException, MalformedObjectNameException, InstanceAlreadyExistsException, NotCompliantMBeanException, | ||
MBeanRegistrationException, NoSuchMethodException, IOException, InvocationTargetException, IllegalAccessException, | ||
InstantiationException { | ||
OLogManager.instance().setConsoleLevel(Level.OFF.getName()); | ||
OServerConfiguration conf = new OServerConfiguration(); | ||
|
||
conf.handlers = new ArrayList<OServerHandlerConfiguration>(); | ||
OServerUserConfiguration rootUser = new OServerUserConfiguration(); | ||
rootUser.name = "root"; | ||
rootUser.password = "root"; | ||
rootUser.resources = "list"; | ||
conf.users = new OServerUserConfiguration[] { rootUser }; | ||
conf.properties = new OServerEntryConfiguration[] { new OServerEntryConfiguration("server.database.path", "target/databases") }; | ||
server = new OServer(); | ||
server.startup(conf); | ||
server.activate(); | ||
ODocument securityConfig = new ODocument(); | ||
securityConfig.fromJSON(OIOUtils.readStreamAsString(this.getClass().getClassLoader().getResourceAsStream("security.json"))); | ||
server.getSecurity().reload(securityConfig); | ||
} | ||
|
||
@After | ||
public void after() { | ||
server.shutdown(); | ||
} | ||
|
||
@Test | ||
public void testServerLoginDatabase() { | ||
server.serverLogin("root", "root", "list"); | ||
} | ||
|
||
@Test | ||
public void testCreateOpenDatabase() { | ||
server.createDatabase("test", ODatabaseType.MEMORY, OrientDBConfig.defaultConfig()); | ||
assertTrue(server.existsDatabase("test")); | ||
ODatabaseSession session = server.openDatabase("test"); | ||
assertNotNull(session); | ||
session.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"enabled": true, | ||
"debug": false, | ||
"server": { | ||
"createDefaultUsers": true | ||
}, | ||
"authentication": { | ||
"enabled": true, | ||
"allowDefault": true, | ||
"authenticators": [ | ||
{ | ||
"name": "Password", | ||
"class": "com.orientechnologies.orient.server.security.authenticator.ODefaultPasswordAuthenticator", | ||
"enabled": true, | ||
"users": [ | ||
{ | ||
"username": "guest", | ||
"resources": "server.listDatabases,server.dblist" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "ServerConfig", | ||
"class": "com.orientechnologies.orient.server.security.authenticator.OServerConfigAuthenticator", | ||
"enabled": true | ||
}, | ||
{ | ||
"name": "SystemAuthenticator", | ||
"class": "com.orientechnologies.orient.server.security.authenticator.OSystemUserAuthenticator", | ||
"enabled": true | ||
} | ||
] | ||
}, | ||
"auditing": { | ||
"class": "com.orientechnologies.security.auditing.ODefaultAuditing", | ||
"enabled": false | ||
} | ||
} |