Search in sources :

Example 1 with SpelTemplateEngineFactory

use of io.gravitee.el.spel.SpelTemplateEngineFactory in project gravitee-access-management by gravitee-io.

the class EnrichProfilePolicyTest method init.

@Before
public void init() {
    reset(configuration, executionContext, request, response);
    Request request = new RequestWrapper(mock(Request.class)) {

        @Override
        public MultiValueMap<String, String> parameters() {
            LinkedMultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
            parameters.add(REQUEST_PARAM, PARAM_VALUE);
            return parameters;
        }
    };
    TemplateEngine tplEngine = new SpelTemplateEngineFactory().templateEngine();
    tplEngine.getTemplateContext().setVariable("request", new EvaluableRequest(request));
    when(executionContext.getTemplateEngine()).thenReturn(tplEngine);
    when(executionContext.getComponent(UserRepository.class)).thenReturn(userRepository);
}
Also used : TemplateEngine(io.gravitee.el.TemplateEngine) LinkedMultiValueMap(io.gravitee.common.util.LinkedMultiValueMap) Request(io.gravitee.gateway.api.Request) EvaluableRequest(io.gravitee.am.gateway.handler.context.EvaluableRequest) RequestWrapper(io.gravitee.gateway.api.RequestWrapper) SpelTemplateEngineFactory(io.gravitee.el.spel.SpelTemplateEngineFactory) EvaluableRequest(io.gravitee.am.gateway.handler.context.EvaluableRequest) Before(org.junit.Before)

Example 2 with SpelTemplateEngineFactory

use of io.gravitee.el.spel.SpelTemplateEngineFactory in project gravitee-access-management by gravitee-io.

the class EnrichAuthFlowPolicyTest method init.

@Before
public void init() {
    reset(configuration, executionContext, request, response, authContextRepository);
    Request request = new RequestWrapper(mock(Request.class)) {

        @Override
        public MultiValueMap<String, String> parameters() {
            LinkedMultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
            parameters.add(REQUEST_PARAM, PARAM_VALUE);
            return parameters;
        }
    };
    TemplateEngine tplEngine = new SpelTemplateEngineFactory().templateEngine();
    tplEngine.getTemplateContext().setVariable("request", new EvaluableRequest(request));
    when(executionContext.getTemplateEngine()).thenReturn(tplEngine);
    when(executionContext.getComponent(AuthenticationFlowContextRepository.class)).thenReturn(this.authContextRepository);
    when(environment.getProperty("authenticationFlow.expirationTimeOut", Integer.class, 300)).thenReturn(300);
    when(executionContext.getComponent(Environment.class)).thenReturn(environment);
}
Also used : TemplateEngine(io.gravitee.el.TemplateEngine) LinkedMultiValueMap(io.gravitee.common.util.LinkedMultiValueMap) Request(io.gravitee.gateway.api.Request) EvaluableRequest(io.gravitee.am.gateway.handler.context.EvaluableRequest) RequestWrapper(io.gravitee.gateway.api.RequestWrapper) SpelTemplateEngineFactory(io.gravitee.el.spel.SpelTemplateEngineFactory) EvaluableRequest(io.gravitee.am.gateway.handler.context.EvaluableRequest) Before(org.junit.Before)

Aggregations

EvaluableRequest (io.gravitee.am.gateway.handler.context.EvaluableRequest)2 LinkedMultiValueMap (io.gravitee.common.util.LinkedMultiValueMap)2 TemplateEngine (io.gravitee.el.TemplateEngine)2 SpelTemplateEngineFactory (io.gravitee.el.spel.SpelTemplateEngineFactory)2 Request (io.gravitee.gateway.api.Request)2 RequestWrapper (io.gravitee.gateway.api.RequestWrapper)2 Before (org.junit.Before)2