Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Notification
Commits
a744a00b
Commit
a744a00b
authored
Jul 01, 2021
by
Nikhil Singh[MicroSoft]
Browse files
Commit 7 Contents:
1-Annotaion Resolution
parent
f5098a5d
Pipeline
#49671
failed with stages
in 2 minutes and 7 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
notification-core/src/main/java/org/opengroup/osdu/notification/auth/GsaAuth.java
View file @
a744a00b
...
...
@@ -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
;
...
...
notification-core/src/main/java/org/opengroup/osdu/notification/auth/HmacAuth.java
View file @
a744a00b
...
...
@@ -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
;
...
...
notification-core/src/main/java/org/opengroup/osdu/notification/auth/factory/AuthFactory.java
View file @
a744a00b
...
...
@@ -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
getSecret
Auth
(
String
secretType
)
{
switch
(
secretType
)
{
case
"HMAC"
:
return
hmacAuth
;
...
...
notification-core/src/main/java/org/opengroup/osdu/notification/service/NotificationHandler.java
View file @
a744a00b
...
...
@@ -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
();
...
...
notification-core/src/test/java/org/opengroup/osdu/notification/service/NotificationHandlerTests.java
View file @
a744a00b
...
...
@@ -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
.
getSecret
Auth
(
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
.
getSecret
Auth
(
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
.
getSecret
Auth
(
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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment