Search in sources :

Example 6 with UserQueryService

use of org.b3log.solo.service.UserQueryService in project solo by b3log.

the class ErrorProcessorTestCase method init.

/**
     * Init.
     *
     * @throws Exception exception
     */
@Test
public void init() throws Exception {
    final InitService initService = getInitService();
    final JSONObject requestJSONObject = new JSONObject();
    requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
}
Also used : JSONObject(org.json.JSONObject) UserQueryService(org.b3log.solo.service.UserQueryService) InitService(org.b3log.solo.service.InitService) Test(org.testng.annotations.Test)

Example 7 with UserQueryService

use of org.b3log.solo.service.UserQueryService in project solo by b3log.

the class IndexProcessorTestCase method init.

/**
     * Init.
     *
     * @throws Exception exception
     */
@Test
public void init() throws Exception {
    final InitService initService = getInitService();
    final JSONObject requestJSONObject = new JSONObject();
    requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
}
Also used : JSONObject(org.json.JSONObject) UserQueryService(org.b3log.solo.service.UserQueryService) InitService(org.b3log.solo.service.InitService) Test(org.testng.annotations.Test)

Example 8 with UserQueryService

use of org.b3log.solo.service.UserQueryService in project solo by b3log.

the class TagProcessorTestCase method init.

/**
     * Init.
     *
     * @throws Exception exception
     */
@Test
public void init() throws Exception {
    final InitService initService = getInitService();
    final JSONObject requestJSONObject = new JSONObject();
    requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
}
Also used : JSONObject(org.json.JSONObject) UserQueryService(org.b3log.solo.service.UserQueryService) InitService(org.b3log.solo.service.InitService) Test(org.testng.annotations.Test)

Example 9 with UserQueryService

use of org.b3log.solo.service.UserQueryService in project solo by b3log.

the class ProcessAuthAdvice method doAdvice.

@Override
public void doAdvice(final HTTPRequestContext context, final Map<String, Object> args) throws RequestProcessAdviceException {
    final LatkeBeanManager beanManager = Lifecycle.getBeanManager();
    final UserQueryService userQueryService = beanManager.getReference(UserQueryService.class);
    if (!userQueryService.isLoggedIn(context.getRequest(), context.getResponse())) {
        try {
            context.getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
        throw new RequestReturnAdviceException(null);
    }
}
Also used : RequestReturnAdviceException(org.b3log.latke.servlet.advice.RequestReturnAdviceException) UserQueryService(org.b3log.solo.service.UserQueryService) IOException(java.io.IOException) LatkeBeanManager(org.b3log.latke.ioc.LatkeBeanManager)

Example 10 with UserQueryService

use of org.b3log.solo.service.UserQueryService in project solo by b3log.

the class ArticleProcessorTestCase method init.

/**
     * Init.
     *
     * @throws Exception exception
     */
@Test
public void init() throws Exception {
    final InitService initService = getInitService();
    final JSONObject requestJSONObject = new JSONObject();
    requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
}
Also used : JSONObject(org.json.JSONObject) UserQueryService(org.b3log.solo.service.UserQueryService) InitService(org.b3log.solo.service.InitService) Test(org.testng.annotations.Test)

Aggregations

UserQueryService (org.b3log.solo.service.UserQueryService)15 JSONObject (org.json.JSONObject)14 InitService (org.b3log.solo.service.InitService)13 Test (org.testng.annotations.Test)13 IOException (java.io.IOException)2 LatkeBeanManager (org.b3log.latke.ioc.LatkeBeanManager)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 RequestReturnAdviceException (org.b3log.latke.servlet.advice.RequestReturnAdviceException)1 UserMgmtService (org.b3log.solo.service.UserMgmtService)1