Search in sources :

Example 1 with XsrfToken

use of com.google.gwt.user.client.rpc.XsrfToken in project ovirt-engine by oVirt.

the class FrontendActionTest method setUp.

@Before
public void setUp() throws Exception {
    mockService = mock(GenericApiGWTServiceAsync.class, withSettings().extraInterfaces(ServiceDefTarget.class));
    fakeScheduler = new FakeGWTScheduler();
    CommunicationProvider communicationsProvider = new GWTRPCCommunicationProvider(mockService, mockXsrfService, mockXsrfRpcRequestBuilder);
    // $NON-NLS-1$
    when(mockXsrfRpcRequestBuilder.getXsrfToken()).thenReturn(new XsrfToken("Something"));
    OperationProcessor operationProcessor = new OperationProcessor(communicationsProvider);
    operationProcessor.setScheduler(fakeScheduler);
    VdcOperationManager operationsManager = new VdcOperationManager(mockEventBus, operationProcessor);
    frontend = new Frontend(operationsManager, mockValidateErrorsTranslator, mockVdsmErrorsTranslator, mockEventBus);
    frontend.setEventsHandler(mockEventsHandler);
    frontend.setConstants(mockConstants);
    frontend.frontendFailureEvent = mockFrontendFailureEvent;
    when(mockConstants.noValidateMessage()).thenReturn(NO_MESSAGE);
}
Also used : GenericApiGWTServiceAsync(org.ovirt.engine.ui.frontend.gwtservices.GenericApiGWTServiceAsync) CommunicationProvider(org.ovirt.engine.ui.frontend.communication.CommunicationProvider) GWTRPCCommunicationProvider(org.ovirt.engine.ui.frontend.communication.GWTRPCCommunicationProvider) GWTRPCCommunicationProvider(org.ovirt.engine.ui.frontend.communication.GWTRPCCommunicationProvider) OperationProcessor(org.ovirt.engine.ui.frontend.communication.OperationProcessor) XsrfToken(com.google.gwt.user.client.rpc.XsrfToken) VdcOperationManager(org.ovirt.engine.ui.frontend.communication.VdcOperationManager) Before(org.junit.Before)

Example 2 with XsrfToken

use of com.google.gwt.user.client.rpc.XsrfToken in project ovirt-engine by oVirt.

the class FrontendTest method setUp.

@Before
public void setUp() throws Exception {
    mockService = mock(GenericApiGWTServiceAsync.class, withSettings().extraInterfaces(ServiceDefTarget.class));
    fakeScheduler = new FakeGWTScheduler();
    CommunicationProvider communicationsProvider = new GWTRPCCommunicationProvider(mockService, mockXsrfService, mockXsrfRpcRequestBuilder);
    // $NON-NLS-1$
    when(mockXsrfRpcRequestBuilder.getXsrfToken()).thenReturn(new XsrfToken("Something"));
    OperationProcessor operationProcessor = new OperationProcessor(communicationsProvider);
    operationProcessor.setScheduler(fakeScheduler);
    VdcOperationManager operationsManager = new VdcOperationManager(mockEventBus, operationProcessor);
    frontend = new Frontend(operationsManager, mockValidateErrorsTranslator, mockVdsmErrorsTranslator, mockEventBus);
    frontend.frontendFailureEvent = mockFrontendFailureEvent;
    frontend.frontendNotLoggedInEvent = mockFrontendNotLoggedInEvent;
    frontend.setEventsHandler(mockEventsHandler);
    frontend.setConstants(mockConstants);
    when(mockAsyncQuery.getModel()).thenReturn(ASYNC_OPERATION_TARGET);
    when(mockAsyncQuery.getAsyncCallback()).thenReturn(mockAsyncCallback);
}
Also used : GenericApiGWTServiceAsync(org.ovirt.engine.ui.frontend.gwtservices.GenericApiGWTServiceAsync) CommunicationProvider(org.ovirt.engine.ui.frontend.communication.CommunicationProvider) GWTRPCCommunicationProvider(org.ovirt.engine.ui.frontend.communication.GWTRPCCommunicationProvider) GWTRPCCommunicationProvider(org.ovirt.engine.ui.frontend.communication.GWTRPCCommunicationProvider) OperationProcessor(org.ovirt.engine.ui.frontend.communication.OperationProcessor) XsrfToken(com.google.gwt.user.client.rpc.XsrfToken) VdcOperationManager(org.ovirt.engine.ui.frontend.communication.VdcOperationManager) Before(org.junit.Before)

Example 3 with XsrfToken

use of com.google.gwt.user.client.rpc.XsrfToken in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method setUp.

@Before
public void setUp() throws Exception {
    mockXsrfRpcRequestBuilder = new XsrfRpcRequestBuilder();
    testProvider = new GWTRPCCommunicationProvider(mockService, mockXsrfService, mockXsrfRpcRequestBuilder);
    // $NON-NLS-1$
    mockXsrfRpcRequestBuilder.setXsrfToken(new XsrfToken("Something"));
}
Also used : XsrfToken(com.google.gwt.user.client.rpc.XsrfToken) Before(org.junit.Before)

Example 4 with XsrfToken

use of com.google.gwt.user.client.rpc.XsrfToken in project ovirt-engine by oVirt.

the class OvirtXsrfProtectedServiceServlet method extractTokenFromRequest.

private XsrfToken extractTokenFromRequest() {
    List<String> header = Collections.list(getThreadLocalRequest().getHeaders(XsrfRpcRequestBuilder.XSRF_TOKEN_HEADER));
    XsrfToken result = null;
    if (header.size() == 1) {
        result = new XsrfToken(header.get(0));
    }
    return result;
}
Also used : XsrfToken(com.google.gwt.user.client.rpc.XsrfToken)

Example 5 with XsrfToken

use of com.google.gwt.user.client.rpc.XsrfToken in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testMissingXsrfToken.

@SuppressWarnings("unchecked")
@Test
public void testMissingXsrfToken() {
    // Remove token so there should be a request for it.
    mockXsrfRpcRequestBuilder.setXsrfToken(null);
    QueryParametersBase testParameters = new QueryParametersBase();
    final List<VdcOperation<QueryType, QueryParametersBase>> operationList = new ArrayList<>();
    final VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameters, null);
    operationList.add(testOperation);
    testProvider.transmitOperation(testOperation);
    verify(mockXsrfService).getNewXsrfToken((AsyncCallback<XsrfToken>) any());
}
Also used : ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) XsrfToken(com.google.gwt.user.client.rpc.XsrfToken) Test(org.junit.Test)

Aggregations

XsrfToken (com.google.gwt.user.client.rpc.XsrfToken)6 Before (org.junit.Before)3 CommunicationProvider (org.ovirt.engine.ui.frontend.communication.CommunicationProvider)2 GWTRPCCommunicationProvider (org.ovirt.engine.ui.frontend.communication.GWTRPCCommunicationProvider)2 OperationProcessor (org.ovirt.engine.ui.frontend.communication.OperationProcessor)2 VdcOperationManager (org.ovirt.engine.ui.frontend.communication.VdcOperationManager)2 GenericApiGWTServiceAsync (org.ovirt.engine.ui.frontend.gwtservices.GenericApiGWTServiceAsync)2 RpcTokenException (com.google.gwt.user.client.rpc.RpcTokenException)1 ArrayList (java.util.ArrayList)1 HttpSession (javax.servlet.http.HttpSession)1 Test (org.junit.Test)1 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1