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
fec7480f
Commit
fec7480f
authored
Nov 18, 2020
by
Rostislav Dublin (EPAM)
Browse files
GONRG-1035
*Logs for Subscription exception response *Docs improvement
parent
72f93c8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
testing/notification-test-gcp/pom.xml
View file @
fec7480f
...
...
@@ -27,7 +27,6 @@
<relativePath>
../pom.xml
</relativePath>
</parent>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
notification-test-gcp
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<name>
notification-test-gcp
</name>
...
...
@@ -51,8 +50,16 @@
<artifactId>
os-core-common
</artifactId>
<version>
0.3.6
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.8
</version>
</dependency>
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-test-lib-gcp
</artifactId>
<version>
0.0.2
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
testing/notification-test-gcp/src/test/java/org/opengroup/osdu/notification/util/GCPTestUtils.java
View file @
fec7480f
package
org.opengroup.osdu.notification.util
;
import
com.google.common.base.Strings
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
class
GCPTestUtils
extends
TestUtils
{
public
GCPTestUtils
()
{
...
...
@@ -41,12 +43,13 @@ public class GCPTestUtils extends TestUtils {
}
private
String
getToken
(
String
testerEnvVar
)
throws
Exception
{
String
serviceAccountFile
=
System
.
getProperty
(
testerEnvVar
,
System
.
getenv
(
testerEnvVar
));
log
.
info
(
"Get {} credentials"
,
testerEnvVar
);
String
serviceAccountValue
=
System
.
getProperty
(
testerEnvVar
,
System
.
getenv
(
testerEnvVar
));
String
audience
=
System
.
getProperty
(
"INTEGRATION_TEST_AUDIENCE"
,
System
.
getenv
(
"INTEGRATION_TEST_AUDIENCE"
));
if
(
Strings
.
isNullOrEmpty
(
audience
))
{
audience
=
"245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com"
;
}
String
token
=
new
GoogleServiceAccount
(
serviceAccount
Fil
e
).
getAuthToken
(
audience
);
String
token
=
new
GoogleServiceAccount
(
serviceAccount
Valu
e
).
getAuthToken
(
audience
);
return
"Bearer "
+
token
;
}
}
testing/notification-test-gcp/src/test/java/org/opengroup/osdu/notification/util/GoogleServiceAccount.java
View file @
fec7480f
...
...
@@ -15,6 +15,7 @@ import org.apache.http.client.methods.HttpPost;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.opengroup.osdu.config.util.DecodedContentExtractor
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
...
...
@@ -24,14 +25,14 @@ import java.util.Base64;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
opengroup
.
osdu
.
config
.
util
.
DecodedContentExtractorUtil
.
NAIVE_JSON_CONTENT_ACCEPTANCE_TESTER
;
public
class
GoogleServiceAccount
{
public
GoogleServiceAccount
(
String
serviceAccountEncoded
)
throws
IOException
{
this
(
Base64
.
getDecoder
().
decode
(
serviceAccountEncoded
));
}
public
GoogleServiceAccount
(
byte
[]
serviceAccountJson
)
throws
IOException
{
try
(
InputStream
inputStream
=
new
ByteArrayInputStream
(
serviceAccountJson
))
{
public
GoogleServiceAccount
(
String
serviceAccountValue
)
throws
IOException
{
serviceAccountValue
=
new
DecodedContentExtractor
(
serviceAccountValue
,
NAIVE_JSON_CONTENT_ACCEPTANCE_TESTER
).
getContent
();
serviceAccount
=
ServiceAccountCredentials
.
fromStream
(
inputStream
);
try
(
InputStream
inputStream
=
new
ByteArrayInputStream
(
serviceAccountValue
.
getBytes
()))
{
this
.
serviceAccount
=
ServiceAccountCredentials
.
fromStream
(
inputStream
);
}
}
...
...
@@ -77,7 +78,6 @@ public class GoogleServiceAccount {
if
(
auth
==
null
){
throw
new
IOException
(
"Failed to retrieve auth token for credentials "
+
jwt
);
}
String
output
=
auth
.
getAsString
();
return
output
;
return
auth
.
getAsString
();
}
}
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