Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Notification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Notification
Commits
fc4b7437
Commit
fc4b7437
authored
1 year ago
by
Guillaume Caillet
Browse files
Options
Downloads
Patches
Plain Diff
Make integration tests more robust by deleting previous subscription
parent
1617f045
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!437
merge code to gitlab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testing/notification-test-aws/src/test/java/org/opengroup/osdu/notification/subscriptions/TestNotificationsEndpoint.java
+26
-15
26 additions, 15 deletions
...notification/subscriptions/TestNotificationsEndpoint.java
with
26 additions
and
15 deletions
testing/notification-test-aws/src/test/java/org/opengroup/osdu/notification/subscriptions/TestNotificationsEndpoint.java
+
26
−
15
View file @
fc4b7437
...
...
@@ -15,6 +15,7 @@ import org.opengroup.osdu.core.common.notification.SubscriptionFactory;
import
org.opengroup.osdu.notification.util.*
;
import
java.util.Arrays
;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
...
...
@@ -44,8 +45,32 @@ public class TestNotificationsEndpoint extends TestBase {
}
@Before
public
void
setup
()
{
public
void
setup
()
throws
Exception
{
this
.
testUtils
=
new
AwsTestUtils
();
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
DpsHeaders
.
DATA_PARTITION_ID
,
TestUtils
.
getOsduTenant
());
headers
.
put
(
DpsHeaders
.
AUTHORIZATION
,
testUtils
.
getOpsToken
());
//hardcoding user here for 200 response tests. This is just initializing the subscription creation
headers
.
put
(
"x-user-id"
,
AwsConfig
.
getAWSCognitoUser
());
DpsHeaders
dpsHeaders
=
DpsHeaders
.
createFromMap
(
headers
);
awssubscriptionService
=
awsfactory
.
create
(
dpsHeaders
);
try
{
// Ensure that there is no previous subscription already registered
// Sometimes this can happen if previous tests didn't exit properly
// Sadly there is no method to delete a subscription from just name, so have
// to manually build the ID like this.
String
subscriptionId
=
String
.
format
(
"%s%s%s"
,
Config
.
Instance
().
Topic
,
PARTITION_TEST
,
Config
.
Instance
().
HMACPushUrl
);
String
encodedSubscriptionId
=
Base64
.
getEncoder
().
encodeToString
(
subscriptionId
.
getBytes
());
awssubscriptionService
.
delete
(
encodedSubscriptionId
);
}
catch
(
Exception
e
)
{}
}
@After
...
...
@@ -57,25 +82,11 @@ public class TestNotificationsEndpoint extends TestBase {
}
private
void
createResourceForTestParition
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
DpsHeaders
.
DATA_PARTITION_ID
,
TestUtils
.
getOsduTenant
());
headers
.
put
(
DpsHeaders
.
AUTHORIZATION
,
testUtils
.
getOpsToken
());
//hardcoding user here for 200 response tests. This is just initializing the subscription creation
headers
.
put
(
"x-user-id"
,
AwsConfig
.
getAWSCognitoUser
());
DpsHeaders
dpsHeaders
=
DpsHeaders
.
createFromMap
(
headers
);
awssubscriptionService
=
awsfactory
.
create
(
dpsHeaders
);
Map
<
String
,
String
>
h
=
dpsHeaders
.
getHeaders
();
System
.
out
.
println
(
h
);
//Create a new subscription to pub/sub
Subscription
subscription
=
new
Subscription
();
subscription
.
setName
(
"Subscription-test-for-notification"
);
subscription
.
setDescription
(
"Subscription with test Partition for fetching notifications"
);
subscription
.
setTopic
(
Config
.
Instance
().
Topic
);
//This seems to be a bug. Don't need to add the string
//subscription.setPushEndpoint(Config.Instance().HMACPushUrl + "hmac-integration-test");
subscription
.
setPushEndpoint
(
Config
.
Instance
().
HMACPushUrl
);
HmacSecret
secret
=
new
HmacSecret
();
secret
.
setValue
(
Config
.
Instance
().
hmacSecretValue
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment