Search in sources :

Example 6 with EzySimpleLoginRequest

use of com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest 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);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) Test(org.testng.annotations.Test)

Example 7 with EzySimpleLoginRequest

use of com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest 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);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzySessionManager(com.tvd12.ezyfoxserver.wrapper.EzySessionManager) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) EzyZoneUserManager(com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleZoneSetting(com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting) Test(org.testng.annotations.Test)

Example 8 with EzySimpleLoginRequest

use of com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest 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);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) Test(org.testng.annotations.Test)

Example 9 with EzySimpleLoginRequest

use of com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest 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);
}
Also used : EzySimpleUserManagementSetting(com.tvd12.ezyfoxserver.setting.EzySimpleUserManagementSetting) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyZoneSetting(com.tvd12.ezyfoxserver.setting.EzyZoneSetting) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) Test(org.testng.annotations.Test)

Example 10 with EzySimpleLoginRequest

use of com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest 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);
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyLoginErrorException(com.tvd12.ezyfoxserver.exception.EzyLoginErrorException) EzySimpleLoginRequest(com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest) EzyUserLoginEvent(com.tvd12.ezyfoxserver.event.EzyUserLoginEvent) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzyLoginController(com.tvd12.ezyfoxserver.controller.EzyLoginController) Test(org.testng.annotations.Test)

Aggregations

EzyArray (com.tvd12.ezyfox.entity.EzyArray)13 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)13 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)13 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)13 EzySimpleLoginRequest (com.tvd12.ezyfoxserver.request.EzySimpleLoginRequest)13 Test (org.testng.annotations.Test)13 EzyLoginController (com.tvd12.ezyfoxserver.controller.EzyLoginController)12 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)11 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)10 EzySimpleUserManagementSetting (com.tvd12.ezyfoxserver.setting.EzySimpleUserManagementSetting)5 EzyZoneSetting (com.tvd12.ezyfoxserver.setting.EzyZoneSetting)5 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)3 EzyZoneUserManager (com.tvd12.ezyfoxserver.wrapper.EzyZoneUserManager)3 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)2 EzyUserLoginEvent (com.tvd12.ezyfoxserver.event.EzyUserLoginEvent)2 EzyLoginErrorException (com.tvd12.ezyfoxserver.exception.EzyLoginErrorException)2 EzySimpleZoneSetting (com.tvd12.ezyfoxserver.setting.EzySimpleZoneSetting)2 EzySimpleStatistics (com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics)2 EzyStatistics (com.tvd12.ezyfoxserver.statistics.EzyStatistics)2 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)2