use of com.tvd12.ezyfoxserver.context.EzySimpleServerContext 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);
}
use of com.tvd12.ezyfoxserver.context.EzySimpleServerContext in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method testEzyZoneNotFoundException.
@Test(expectedExceptions = EzyZoneNotFoundException.class)
public void testEzyZoneNotFoundException() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
data.set(0, "not found");
EzyLoginController controller = new EzyLoginController();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
}
use of com.tvd12.ezyfoxserver.context.EzySimpleServerContext in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method fireUserAddedEvent0ExceptionCase.
@Test
public void fireUserAddedEvent0ExceptionCase() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzyLoginProcessor processor = new EzyLoginProcessor(ctx);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(zoneContext.getZone()).thenReturn(ctx.getZoneContext("example").getZone());
doThrow(new IllegalStateException()).when(zoneContext).broadcastPlugins(any(EzyConstant.class), any(EzyEvent.class), anyBoolean());
MethodInvoker.create().method("doFireUserAddedEvent").object(processor).param(EzyZoneContext.class, zoneContext).param(EzyEvent.class, mock(EzyEvent.class)).invoke();
}
use of com.tvd12.ezyfoxserver.context.EzySimpleServerContext in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method test.
@Test
public void test() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
EzyLoginController controller = new EzyLoginController();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
controller.handle(ctx, request);
}
use of com.tvd12.ezyfoxserver.context.EzySimpleServerContext in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method processChangeSessionTest.
@Test
public void processChangeSessionTest() {
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(true);
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);
}
Aggregations