Commit a744a00b authored by Nikhil Singh[MicroSoft]'s avatar Nikhil Singh[MicroSoft]
Browse files

Commit 7 Contents:

1-Annotaion Resolution
parent f5098a5d
Pipeline #49671 failed with stages
in 2 minutes and 7 seconds
......@@ -24,11 +24,13 @@ import org.opengroup.osdu.notification.auth.interfaces.SecretAuth;
import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import java.util.HashMap;
import java.util.Map;
@Component
@RequestScope
public class GsaAuth implements SecretAuth {
@Autowired
private IGoogleServiceAccount gsaTokenProvider;
......
......@@ -21,11 +21,13 @@ import org.opengroup.osdu.core.common.model.notification.Secret;
import org.opengroup.osdu.notification.auth.interfaces.SecretAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import java.util.HashMap;
import java.util.Map;
@Component
@RequestScope
public class HmacAuth implements SecretAuth {
@Autowired
private ISignatureService signatureService;
......
......@@ -16,12 +16,12 @@
package org.opengroup.osdu.notification.auth.factory;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.notification.Secret;
import org.opengroup.osdu.notification.auth.GsaAuth;
import org.opengroup.osdu.notification.auth.HmacAuth;
import org.opengroup.osdu.notification.auth.interfaces.SecretAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Component
public class AuthFactory {
......@@ -32,7 +32,7 @@ public class AuthFactory {
@Autowired
private JaxRsDpsLog log;
public SecretAuth getSecret(String secretType) {
public SecretAuth getSecretAuth(String secretType) {
switch (secretType) {
case "HMAC":
return hmacAuth;
......
......@@ -27,6 +27,7 @@ import org.opengroup.osdu.notification.auth.interfaces.SecretAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import java.util.HashMap;
import java.util.Map;
......@@ -50,10 +51,10 @@ public class NotificationHandler {
String endpoint = subscription.getPushEndpoint();
String secretType = secret.getSecretType();
String pushUrl = "";
Map<String, String> requestHeader = new HashMap<>();
// Authentication Secret
Map<String, String> requestHeader = new HashMap<String,String>();
SecretAuth secretAuth = authFactory.getSecret(secretType);
// Authentication Secret
SecretAuth secretAuth = authFactory.getSecretAuth(secretType);
secretAuth.setSecret(secret);
pushUrl = secretAuth.getPushUrl(endpoint);
requestHeader = secretAuth.getRequestHeaders();
......
......@@ -70,7 +70,7 @@ public class NotificationHandlerTests {
response.setResponseCode(200);
Map<String, String> headers = new HashMap<String, String>();
when(this.subscriptionHandler.getSubscriptionFromCache(this.NOTIFICATION_ID)).thenReturn(gsa_subscription);
when(this.authFactory.getSecret(any())).thenReturn(secretAuth);
when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth);
when(this.httpClient.send(any())).thenReturn(response);
when(this.secretAuth.getPushUrl(gsa_subscription.getPushEndpoint())).thenReturn(gsa_subscription.getPushEndpoint());
when(this.secretAuth.getRequestHeaders()).thenReturn(headers);
......@@ -83,7 +83,7 @@ public class NotificationHandlerTests {
response.setResponseCode(200);
Map<String, String> headers = new HashMap<String, String>();
when(this.subscriptionHandler.getSubscriptionFromCache(this.NOTIFICATION_ID)).thenReturn(hmac_subscription);
when(this.authFactory.getSecret(any())).thenReturn(secretAuth);
when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth);
when(this.httpClient.send(any())).thenReturn(response);
when(this.secretAuth.getPushUrl(hmac_subscription.getPushEndpoint())).thenReturn(hmac_subscription.getPushEndpoint());
when(this.secretAuth.getRequestHeaders()).thenReturn(headers);
......@@ -94,7 +94,7 @@ public class NotificationHandlerTests {
@Test(expected = SubscriptionException.class)
public void should_throwException_whenSubscriptionHandlerThrowsException() throws Exception {
Map<String, String> headers = new HashMap<String, String>();
when(this.authFactory.getSecret(any())).thenReturn(secretAuth);
when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth);
when(this.httpClient.send(any())).thenReturn(response);
when(this.secretAuth.getPushUrl(gsa_subscription.getPushEndpoint())).thenReturn(gsa_subscription.getPushEndpoint());
when(this.secretAuth.getRequestHeaders()).thenReturn(headers);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment