Skip to content
Snippets Groups Projects
Unverified Commit a6b36f4d authored by Timm Fitschen's avatar Timm Fitschen
Browse files

TST: fix tests

parent 206b6f89
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,7 @@ public class UserSources extends HashMap<String, UserSource> {
/**
* Return the roles of a given user.
*
* @param realm
* @param username
* @return
......
......@@ -170,6 +170,7 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
/**
* Add the user info to the Response Element.
*
* @param retRoot
* @param user
*/
......@@ -208,6 +209,7 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
/**
* Add the username and the realm of the current user to the user info (as attributes).
*
* @param userInfo
*/
private void addNameAndRealm(Element userInfo, Subject user) {
......
package caosdb.server.resource;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import caosdb.server.CaosDBException;
import caosdb.server.accessControl.AnonymousAuthenticationToken;
import caosdb.server.accessControl.AnonymousRealm;
import caosdb.server.database.backend.implementation.MySQL.ConnectionException;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.SimpleAccount;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.session.mgt.DelegatingSession;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.support.DelegatingSubject;
import org.jdom2.Element;
import org.junit.Test;
import org.restlet.data.Reference;
import org.restlet.representation.Representation;
import caosdb.server.CaosDBException;
import caosdb.server.accessControl.AnonymousAuthenticationToken;
import caosdb.server.accessControl.AnonymousRealm;
import caosdb.server.accessControl.CaosDBAuthorizingRealm;
import caosdb.server.database.backend.implementation.MySQL.ConnectionException;
public class TestAbstractCaosDBServerResource {
......@@ -27,11 +24,13 @@ public class TestAbstractCaosDBServerResource {
public void testReponseRootElement() {
final Subject user = new DelegatingSubject(new DefaultSecurityManager(new AnonymousRealm()));
user.login(AnonymousAuthenticationToken.getInstance());
AbstractCaosDBServerResource s = new AbstractCaosDBServerResource() {
AbstractCaosDBServerResource s =
new AbstractCaosDBServerResource() {
@Override
protected Representation httpGetInChildClass() throws ConnectionException, IOException,
SQLException, CaosDBException, NoSuchAlgorithmException, Exception {
protected Representation httpGetInChildClass()
throws ConnectionException, IOException, SQLException, CaosDBException,
NoSuchAlgorithmException, Exception {
// TODO Auto-generated method stub
return null;
}
......@@ -68,7 +67,5 @@ public class TestAbstractCaosDBServerResource {
assertEquals("TEST-CRID", response.getAttribute("crid").getValue());
assertEquals("0", response.getAttribute("timestamp").getValue());
assertEquals("https://example.com/root/", response.getAttributeValue("baseuri"));
Element userInfo = response.getChild("UserInfo");
assertNotNull(userInfo);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment