/** * Sets the authentication headers. * * @param soapClient the SOAP client * @param adManagerSession the Ad Manager session * @throws AuthenticationException if there was a problem getting/setting the header */ private void setAuthenticationHeaders(Object soapClient, AdManagerSession adManagerSession) throws AuthenticationException { authorizationHeaderHandler.setAuthorization(soapClient, adManagerSession); }
@SuppressWarnings("unchecked") @Before public void setUp() { MockitoAnnotations.initMocks(this); authorizationHeaderHandler = new AuthorizationHeaderHandler(soapClientHandler, authorizationHeaderProvider); }
/** * Sets the authentication headers. * * @param soapClient the SOAP client * @param adManagerSession the Ad Manager session * @throws AuthenticationException if there was a problem getting/setting the authorization header * @throws IllegalArgumentException if there was a problem setting the header */ private void setAuthenticationHeaders(Object soapClient, AdManagerSession adManagerSession) throws AuthenticationException { authorizationHeaderHandler.setAuthorization(soapClient, adManagerSession); }
/** * Sets the authentication headers. * * @param soapClient the SOAP client * @param headerElements the map housing header elements * @param adWordsSession the AdWords session * @throws AuthenticationException if there was a problem getting/setting the * header */ @VisibleForTesting void setAuthenticationHeaders(Object soapClient, Map<String, Object> headerElements, AdWordsSession adWordsSession) throws AuthenticationException { authorizationHeaderHandler.setAuthorization(soapClient, adWordsSession); }
@SuppressWarnings("unchecked") @Test public void testSetAuthorization() throws Exception { String authorizationHeaderValue = "IAmAuthorized"; final String endpoint = "endpoint"; Object soapClient = new Object(); AdsSession adsSession = () -> endpoint; @SuppressWarnings("rawtypes") ArgumentCaptor<Map> headers = ArgumentCaptor.forClass(Map.class); when(soapClientHandler.getEndpointAddress(soapClient)).thenReturn(endpoint); when(authorizationHeaderProvider.getAuthorizationHeader( same(adsSession), eq(endpoint))).thenReturn(authorizationHeaderValue); authorizationHeaderHandler.setAuthorization(soapClient, adsSession); verify(soapClientHandler).putAllHttpHeaders(eq(soapClient), headers.capture()); String actualAuthorizationHeaderValue = (String) headers.getValue().get("Authorization"); assertEquals(authorizationHeaderValue, actualAuthorizationHeaderValue); } }
soapClientHandler.setRequestTimeout(stub, adsLibConfiguration.getSoapRequestTimeout()); authorizationHeaderHandler.setAuthorization(soapClient, adWordsSession); } catch (InstantiationException | IllegalAccessException
soapClientHandler.setRequestTimeout(stub, adsLibConfiguration.getSoapRequestTimeout()); authorizationHeaderHandler.setAuthorization(soapClient, adWordsSession); } catch (InstantiationException | IllegalAccessException