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
Security and Compliance
entitlements-aws
Commits
a5857dd8
Commit
a5857dd8
authored
Sep 02, 2020
by
Matt Wise
Browse files
Fix integration tests
parent
24178f31
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
.fossa.yml
View file @
a5857dd8
...
...
@@ -11,8 +11,4 @@ analyze:
-
name
:
os-entitlements-aws
type
:
mvn
target
:
pom.xml
path
:
.
-
name
:
Entitlements Functions
type
:
mvn
target
:
EntitlementsFunctions/pom.xml
path
:
.
path
:
.
\ No newline at end of file
.gitlab-ci.yml
View file @
a5857dd8
...
...
@@ -25,4 +25,4 @@ include:
# is no javascript to scan, so the job isn't helpful and just gets in the way
eslint-sast
:
rules
:
-
when
:
never
-
when
:
never
\ No newline at end of file
NOTICE
View file @
a5857dd8
This diff is collapsed.
Click to expand it.
testing/entitlements-test-aws/build-aws/run-tests.sh
View file @
a5857dd8
...
...
@@ -38,7 +38,7 @@ export DEPLOY_ENV=empty
export
AWS_COGNITO_AUTH_FLOW
=
USER_PASSWORD_AUTH
export
AWS_COGNITO_AUTH_PARAMS_USER
=
$ADMIN_USER
export
AWS_COGNITO_AUTH_PARAMS_PASSWORD
=
$ADMIN_PASSWORD
export
MY
_TENANT
=
opendes-int
export
ENTITLEMENTS_TEST
_TENANT
=
opendes-int
export
DOMAIN
=
testing.com
...
...
testing/entitlements-test-aws/src/test/java/org/opengroup/osdu/entitlements/apiTests/EntitlementsApiTests.java
View file @
a5857dd8
...
...
@@ -42,14 +42,11 @@ public class EntitlementsApiTests {
envhelper
.
createCognitoUser
(
AwsConfig
.
getAWSCognitoUserPoolID
(),
AwsConfig
.
getAWSCognitoTestUsername
(),
"Password@123"
,
AwsConfig
.
getAWSCognitoTestUserPassword
());
envhelper
.
add_test_tenant
();
envhelper
.
add_groups
();
}
@Test
public
void
getGroupsTest_ok
()
throws
Exception
{
String
path
=
"groups"
;
ClientResponse
response
=
HTTPUtil
.
send
(
path
,
"GET"
,
HTTPUtil
.
getHeaders
(),
""
,
""
);
...
...
testing/entitlements-test-aws/src/test/java/org/opengroup/osdu/entitlements/utils/AwsConfig.java
View file @
a5857dd8
...
...
@@ -64,7 +64,7 @@ public class AwsConfig {
}
public
static
String
getTenant
()
{
return
getEnvironmentVariableOrDefaultValue
(
"
MY
_TENANT"
,
"opendes-int"
);
return
getEnvironmentVariableOrDefaultValue
(
"
ENTITLEMENTS_TEST
_TENANT"
,
"opendes-int"
);
}
...
...
testing/entitlements-test-aws/src/test/java/org/opengroup/osdu/entitlements/utils/EnvHelper.java
View file @
a5857dd8
...
...
@@ -52,8 +52,11 @@ public class EnvHelper {
AWSCognitoIdentityProvider
provider
=
client
.
getProvider
();
String
awsCognitoClientId
=
AwsConfig
.
getAWSCognitoClientId
();
AuthenticationResultType
authenticationResult
=
null
;
AdminCreateUserRequest
cognitoRequest
=
new
AdminCreateUserRequest
()
try
{
AdminCreateUserRequest
cognitoRequest
=
new
AdminCreateUserRequest
()
.
withUserPoolId
(
userpoolid
)
.
withUsername
(
test_username
)
.
withUserAttributes
(
...
...
@@ -67,30 +70,38 @@ public class EnvHelper {
.
withMessageAction
(
"SUPPRESS"
)
.
withDesiredDeliveryMediums
(
DeliveryMediumType
.
EMAIL
)
.
withForceAliasCreation
(
Boolean
.
FALSE
);
AdminCreateUserResult
createUserResult
=
provider
.
adminCreateUser
(
cognitoRequest
);
UserType
cognitoUser
=
createUserResult
.
getUser
();
AdminCreateUserResult
createUserResult
=
provider
.
adminCreateUser
(
cognitoRequest
);
String
session_token
=
client
.
getToken
(
test_username
,
temppassword
,
"session"
);
UserType
cognitoUser
=
createUserResult
.
getUser
(
);
String
session_token
=
client
.
getToken
(
test_username
,
temppassword
,
"session"
);
//CONFIRM the user
final
Map
<
String
,
String
>
challengeResponses
=
new
HashMap
<>();
challengeResponses
.
put
(
"USERNAME"
,
test_username
);
challengeResponses
.
put
(
"NEW_PASSWORD"
,
newpassword
);
//populate the challenge response
final
AdminRespondToAuthChallengeRequest
request
=
new
AdminRespondToAuthChallengeRequest
();
request
.
withChallengeName
(
ChallengeNameType
.
NEW_PASSWORD_REQUIRED
)
.
withChallengeResponses
(
challengeResponses
)
.
withClientId
(
awsCognitoClientId
)
.
withUserPoolId
(
userpoolid
)
.
withSession
(
session_token
);
//CONFIRM the user
final
Map
<
String
,
String
>
challengeResponses
=
new
HashMap
<>();
challengeResponses
.
put
(
"USERNAME"
,
test_username
);
challengeResponses
.
put
(
"NEW_PASSWORD"
,
newpassword
);
//populate the challenge response
final
AdminRespondToAuthChallengeRequest
request
=
new
AdminRespondToAuthChallengeRequest
();
request
.
withChallengeName
(
ChallengeNameType
.
NEW_PASSWORD_REQUIRED
)
.
withChallengeResponses
(
challengeResponses
)
.
withClientId
(
awsCognitoClientId
)
.
withUserPoolId
(
userpoolid
)
.
withSession
(
session_token
);
AdminRespondToAuthChallengeResult
resultChallenge
=
provider
.
adminRespondToAuthChallenge
(
request
);
authenticationResult
=
resultChallenge
.
getAuthenticationResult
();
AdminRespondToAuthChallengeResult
resultChallenge
=
provider
.
adminRespondToAuthChallenge
(
request
);
authenticationResult
=
resultChallenge
.
getAuthenticationResult
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
throw
e
;
}
}
...
...
@@ -124,44 +135,52 @@ public class EnvHelper {
public
void
add_groups
()
{
System
.
out
.
println
(
"Adding the test groups to user: "
+
AwsConfig
.
getAWSCognitoTestUsername
()+
" now.."
);
String
tableName
=
tablePrefix
+
"-"
+
"Groups"
;
Table
table
=
dynamoDB
.
getTable
(
tableName
);
List
<
String
>
groups
=
new
ArrayList
<
String
>();
groups
.
add
(
"data.default.viewers"
);
groups
.
add
(
"data.file.WellboreTrajectory"
);
groups
.
add
(
"service.storage.viewer"
);
groups
.
add
(
"service.search.user"
);
groups
.
add
(
"service.entitlements.admin"
);
String
dataPartitionId
=
AwsConfig
.
getTenant
();
String
domain
=
AwsConfig
.
getDomain
();
String
memberEmail
=
AwsConfig
.
getAWSCognitoTestUsername
();
for
(
String
group
:
groups
)
{
String
groupName
=
group
;
String
groupDescription
=
group
;
String
groupEmail
=
String
.
format
(
"%s@%s.%s"
,
groupName
,
dataPartitionId
,
domain
);
String
groupUniqueIdentifier
=
String
.
format
(
"%s:%s:%s"
,
dataPartitionId
,
groupEmail
,
memberEmail
);
String
memberEmailAndDataPartition
=
String
.
format
(
"%s:%s"
,
memberEmail
,
dataPartitionId
);
// Build the item
Item
item
=
new
Item
()
.
withString
(
"groupUniqueIdentifier"
,
groupUniqueIdentifier
)
.
withString
(
"dataPartitionId"
,
dataPartitionId
)
.
withString
(
"groupDescription"
,
groupDescription
)
.
withString
(
"groupEmail"
,
groupEmail
)
.
withString
(
"groupName"
,
groupName
)
.
withString
(
"memberEmail"
,
memberEmail
)
.
withString
(
"memberEmailAndDataPartition"
,
memberEmailAndDataPartition
)
.
withString
(
"role"
,
"OWNER"
);
// Write the item to the table
PutItemOutcome
outcome
=
table
.
putItem
(
item
);
try
{
System
.
out
.
println
(
"Adding the test groups to user: "
+
AwsConfig
.
getAWSCognitoTestUsername
()+
" now.."
);
String
tableName
=
tablePrefix
+
"-"
+
"Groups"
;
Table
table
=
dynamoDB
.
getTable
(
tableName
);
List
<
String
>
groups
=
new
ArrayList
<
String
>();
groups
.
add
(
"data.default.viewers"
);
groups
.
add
(
"data.file.WellboreTrajectory"
);
groups
.
add
(
"service.storage.viewer"
);
groups
.
add
(
"service.search.user"
);
groups
.
add
(
"service.entitlements.admin"
);
String
dataPartitionId
=
AwsConfig
.
getTenant
();
String
domain
=
AwsConfig
.
getDomain
();
String
memberEmail
=
AwsConfig
.
getAWSCognitoTestUsername
();
for
(
String
group
:
groups
)
{
String
groupName
=
group
;
String
groupDescription
=
group
;
String
groupEmail
=
String
.
format
(
"%s@%s.%s"
,
groupName
,
dataPartitionId
,
domain
);
String
groupUniqueIdentifier
=
String
.
format
(
"%s:%s:%s"
,
dataPartitionId
,
groupEmail
,
memberEmail
);
String
memberEmailAndDataPartition
=
String
.
format
(
"%s:%s"
,
memberEmail
,
dataPartitionId
);
// Build the item
Item
item
=
new
Item
()
.
withString
(
"groupUniqueIdentifier"
,
groupUniqueIdentifier
)
.
withString
(
"dataPartitionId"
,
dataPartitionId
)
.
withString
(
"groupDescription"
,
groupDescription
)
.
withString
(
"groupEmail"
,
groupEmail
)
.
withString
(
"groupName"
,
groupName
)
.
withString
(
"memberEmail"
,
memberEmail
)
.
withString
(
"memberEmailAndDataPartition"
,
memberEmailAndDataPartition
)
.
withString
(
"role"
,
"OWNER"
);
// Write the item to the table
PutItemOutcome
outcome
=
table
.
putItem
(
item
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
throw
e
;
}
}
public
void
delete_test_tenant
()
{
...
...
Write
Preview
Markdown
is supported
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