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);
}
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);
}
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"));
}
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;
}
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());
}
Aggregations