use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method testEzyMaxUserExceptionCase.
@SuppressWarnings("rawtypes")
@Test(expectedExceptions = EzyMaxUserException.class)
public void testEzyMaxUserExceptionCase() {
EzyServerContext ctx = mock(EzyServerContext.class);
EzyStatistics userStats = new EzySimpleStatistics();
EzySimpleServer server = new EzySimpleServer();
server.setStatistics(userStats);
when(ctx.getServer()).thenReturn(server);
server.setResponseApi(mock(EzyResponseApi.class));
EzySessionManager sessionManager = mock(EzySessionManager.class);
server.setSessionManager(sessionManager);
EzyZoneContext zoneContext = mock(EzyZoneContext.class);
when(ctx.getZoneContext("example")).thenReturn(zoneContext);
EzySimpleZone zone = new EzySimpleZone();
EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
zone.setSetting(zoneSetting);
when(zoneContext.getZone()).thenReturn(zone);
EzyZoneUserManager zoneUserManager = EzyZoneUserManagerImpl.builder().maxUsers(1).build();
zone.setUserManager(zoneUserManager);
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);
data.set(1, "test1");
request.deserializeParams(data);
controller.handle(ctx, request);
}
use of com.tvd12.ezyfoxserver.entity.EzySession 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.entity.EzySession 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);
}
use of com.tvd12.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method test2.
@Test(expectedExceptions = { EzyLoginErrorException.class })
public void test2() {
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() {
@Override
protected void firePluginEvent(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.ezyfoxserver.entity.EzySession in project ezyfox-server by youngmonkeys.
the class EzyHandShakeController2Test method test.
@Test
public void test() {
EzyServerContext ctx = newServerContext();
EzySession first = getSessionManager(ctx).provideSession(EzyConnectionType.SOCKET);
System.err.println("first.token: " + first);
System.err.println("alive sessions: " + getSessionManager(ctx).getAliveSessions());
assertTrue(getSessionManager(ctx).containsSession(first.getId()));
EzySession session = getSessionManager(ctx).provideSession(EzyConnectionType.SOCKET);
System.err.println("session: " + session);
EzyArray data = newHandShakeData(first.getToken());
EzySimpleHandshakeRequest request = new EzySimpleHandshakeRequest();
request.deserializeParams(data);
request.setSession(session);
EzyHandshakeParams requestParams = request.getParams();
assertEquals(first.getToken(), requestParams.getReconnectToken());
EzyHandshakeController controller = new EzyHandshakeController();
controller.handle(ctx, request);
}
Aggregations