use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method maximumSession1Test.
@Test(expectedExceptions = EzyLoginErrorException.class)
public void maximumSession1Test() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
EzyZoneContext zoneContext = ctx.getZoneContext("example");
EzyZoneSetting zoneSetting = zoneContext.getZone().getSetting();
EzySimpleUserManagementSetting userManagementSetting = (EzySimpleUserManagementSetting) zoneSetting.getUserManagement();
userManagementSetting.setMaxSessionPerUser(0);
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
data.set(1, "");
EzyLoginController controller = new EzyLoginController();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method testSetUserProperties.
@Test
public void testSetUserProperties() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
EzyLoginProcessor processor = new EzyLoginProcessor(ctx);
EzyZoneContext zoneContext = ctx.getZoneContext("example");
EzyLoginParams params = request.getParams();
EzySimpleUserLoginEvent event = new EzySimpleUserLoginEvent(session, params.getZoneName(), params.getUsername(), params.getPassword(), params.getData());
event.setUserProperty("dataId", 123L);
processor.apply(zoneContext, event);
event.release();
EzyZoneUserManager userManager = zoneContext.getZone().getUserManager();
EzyUser user = userManager.getUser("dungtv");
assert user.getProperty("dataId").equals(123L);
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method test1.
@Test(expectedExceptions = { EzyLoginErrorException.class })
public void test1() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData1();
EzyLoginController controller = new EzyLoginController() {
@Override
protected void process(EzyServerContext ctx, EzyZoneContext zoneContext, EzyUserLoginEvent event) {
throw new EzyLoginErrorException();
}
};
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method maximumSession3Test.
@Test(expectedExceptions = EzyLoginErrorException.class)
public void maximumSession3Test() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
EzyZoneContext zoneContext = ctx.getZoneContext("example");
EzyZoneSetting zoneSetting = zoneContext.getZone().getSetting();
EzySimpleUserManagementSetting userManagementSetting = (EzySimpleUserManagementSetting) zoneSetting.getUserManagement();
userManagementSetting.setMaxSessionPerUser(1);
userManagementSetting.setAllowChangeSession(false);
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
data.set(1, "helloworld");
EzyLoginController controller = new EzyLoginController();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
controller.handle(ctx, request);
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method maximumSession2Test.
@Test(expectedExceptions = EzyLoginErrorException.class)
public void maximumSession2Test() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
EzyZoneContext zoneContext = ctx.getZoneContext("example");
EzyZoneSetting zoneSetting = zoneContext.getZone().getSetting();
EzySimpleUserManagementSetting userManagementSetting = (EzySimpleUserManagementSetting) zoneSetting.getUserManagement();
userManagementSetting.setMaxSessionPerUser(2);
userManagementSetting.setAllowChangeSession(false);
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession(1);
session.setToken("abcdef");
EzyArray data = newLoginData();
data.set(1, "helloworld");
EzyLoginController controller = new EzyLoginController();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
request.setSession(newSession(2));
controller.handle(ctx, request);
request.setSession(newSession(3));
controller.handle(ctx, request);
}
Aggregations