Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pipeline injector on workspacepitest #3055

Open
wants to merge 74 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
0f65a22
use pipeline injector on workspacepitest
jyang-broad Sep 30, 2024
797bb10
add implicits
jyang-broad Sep 30, 2024
d645157
retest
jyang-broad Sep 30, 2024
38bfe5b
import pipeline
jyang-broad Sep 30, 2024
ffb2b86
fix student
jyang-broad Oct 1, 2024
3540e04
Add scope?
jyang-broad Oct 1, 2024
7b7b5e4
revert billing scope, remove extra token value
jyang-broad Oct 1, 2024
d4a88e0
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 1, 2024
54b2a43
retest
jyang-broad Oct 2, 2024
b468ef9
update branch back to main, removed the rest of workspace auth instances
jyang-broad Oct 2, 2024
0cb883e
testing: remove create bee and run just against my bee
jyang-broad Oct 2, 2024
bcfe922
move to demo branch
jyang-broad Oct 2, 2024
6e2aaa1
retest
jyang-broad Oct 8, 2024
4b74dcc
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 8, 2024
fc75513
update billing spec
jyang-broad Oct 8, 2024
a0e94e9
Merge remote-tracking branch 'refs/remotes/origin/DDO-3838-use-pipeli…
jyang-broad Oct 8, 2024
6d6f564
add pipeline lib
jyang-broad Oct 8, 2024
304a1f1
use nonownertoken
jyang-broad Oct 17, 2024
f92f70c
no implicit
jyang-broad Oct 17, 2024
a9f9c18
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 17, 2024
cdf26eb
retest
jyang-broad Oct 17, 2024
b823881
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 18, 2024
c9ff6d8
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 18, 2024
a49a012
try ownerauthtoken
jyang-broad Oct 18, 2024
f74e8a7
Merge remote-tracking branch 'refs/remotes/origin/DDO-3838-use-pipeli…
jyang-broad Oct 18, 2024
c770407
try scope
jyang-broad Oct 18, 2024
3208293
try bearer
jyang-broad Oct 18, 2024
f584749
try access token
jyang-broad Oct 21, 2024
8a95b49
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 21, 2024
3b47e9d
try value
jyang-broad Oct 21, 2024
e631e29
remove cleanup?
jyang-broad Oct 21, 2024
f0a403a
unimplicit auth token
jyang-broad Oct 22, 2024
5c41d7f
typo
jyang-broad Oct 22, 2024
80d7107
typo
jyang-broad Oct 22, 2024
a9b5399
convert AuthDomainSpec to pipeline
jyang-broad Oct 22, 2024
c8a3b4a
add pipeline
jyang-broad Oct 22, 2024
74a9979
typo?
jyang-broad Oct 22, 2024
daa4536
a list
jyang-broad Oct 22, 2024
185a4fb
a list fix
jyang-broad Oct 22, 2024
44ba404
no option
jyang-broad Oct 22, 2024
91b784b
try no userdata
jyang-broad Oct 22, 2024
cc00aae
undo
jyang-broad Oct 22, 2024
a0d8f9f
oops, didn't actually get the token
jyang-broad Oct 23, 2024
1ae64ba
uh, fix, maybe
jyang-broad Oct 23, 2024
88a754a
no get
jyang-broad Oct 23, 2024
aecbe16
unzip?
jyang-broad Oct 23, 2024
abc5b7b
just hardcode it
jyang-broad Oct 23, 2024
12ad477
no get
jyang-broad Oct 23, 2024
c18e244
pipeline fixes
jyang-broad Oct 23, 2024
e43bdfc
fix typing
jyang-broad Oct 23, 2024
cb8e108
use billing pipeline
jyang-broad Oct 23, 2024
a3b4427
fix typo
jyang-broad Oct 23, 2024
73ee8bc
fix studentB
jyang-broad Oct 23, 2024
ab05325
fix studentA
jyang-broad Oct 23, 2024
e2840d0
fix workspaceapispec
jyang-broad Oct 23, 2024
fb10604
don't cast
jyang-broad Oct 23, 2024
f19c4bc
uncast again
jyang-broad Oct 23, 2024
81fc530
oops bee
jyang-broad Oct 23, 2024
602cccd
add debug
jyang-broad Oct 24, 2024
bc67cbc
use seq?
jyang-broad Oct 24, 2024
cfc65d0
try no random
jyang-broad Oct 24, 2024
7d62dda
more debug
jyang-broad Oct 24, 2024
3ffa94f
retest
jyang-broad Oct 24, 2024
bdb66c0
remove one json
jyang-broad Oct 24, 2024
e59c058
remove more pem
jyang-broad Oct 24, 2024
e92a24c
un-implicit stuff
jyang-broad Oct 24, 2024
edd20da
remove from with cleanup
jyang-broad Oct 24, 2024
02f4988
Merge branch 'develop' into DDO-3838-use-pipeline-injector
jyang-broad Oct 24, 2024
caf9602
us sa token
jyang-broad Oct 24, 2024
8871183
retest
jyang-broad Oct 24, 2024
3b6c765
retest
jyang-broad Nov 14, 2024
a0577ad
retest
jyang-broad Nov 14, 2024
3255810
retest
jyang-broad Nov 14, 2024
aa4dd8e
Merge branch 'develop' into DDO-3838-use-pipeline-injector
kevinmarete Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/rawls-build-tag-publish-and-run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- rawls-build-publish-job
if: false
permissions:
contents: 'read'
id-token: 'write'
Expand Down Expand Up @@ -178,7 +179,7 @@ jobs:
name: ${{ matrix.test-group.group_name }}-owned tests
runs-on: ubuntu-latest
needs:
- create-bee-workflow
# - create-bee-workflow
- init-github-context
permissions:
contents: 'read'
Expand All @@ -193,16 +194,18 @@ jobs:
run-name: "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}-${{ matrix.terra-env }}-${{ matrix.testing-env }}-${{ matrix.test-group.group_name }}"
workflow: .github/workflows/rawls-swat-tests.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
ref: refs/heads/DDO-3838-test-remove-confs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

token: ${{ secrets.BROADBOT_TOKEN }} # github token for access to kick off a job in the private repo
# manually recalculate b/c env context is broken https://github.com/actions/runner/issues/480
# "bee-name": "${{ env.BEE_NAME }}-${{ matrix.terra-env }}",
inputs: '{
"additional-args": "{\"logging\":\"true\",\"java-version\":\"17\",\"billing-project\":\"\"}",
"run-name": "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}-${{ matrix.terra-env }}-${{ matrix.testing-env }}-${{ matrix.test-group.group_name }}",
"bee-name": "${{ env.BEE_NAME }}-${{ matrix.terra-env }}",
"bee-name": "juyang-swatomation-vervet",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert?

"ENV": "${{ matrix.testing-env }}",
"test-group-name": "${{ matrix.test-group.group_name }}",
"test-command": "${{ env.rawls_base_test_entrypoint }} ${{ matrix.test-group.tag }}",
"e2e-env": "rawls_bee.env",
"test-context": "${{ env.test-context }}",
"ref": "${{ needs.init-github-context.outputs.ref }}"
}'
Expand All @@ -215,7 +218,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- rawls-swat-test-job
if: always() # always run to confirm bee is destroyed
if: false # always() # always run to confirm bee is destroyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert?

permissions:
contents: 'read'
id-token: 'write'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.broadinstitute.dsde.test.api
import cats.implicits.catsSyntaxOptionId
import org.broadinstitute.dsde.rawls.model.WorkspaceJsonSupport._
import org.broadinstitute.dsde.rawls.model.WorkspaceResponse
import org.broadinstitute.dsde.test.pipeline._
import org.broadinstitute.dsde.workbench.auth.AuthToken
import org.broadinstitute.dsde.workbench.auth.AuthTokenScopes.{billingScopes, serviceAccountScopes}
import org.broadinstitute.dsde.workbench.config.{ServiceTestConfig, UserPool}
Expand All @@ -29,63 +30,62 @@ class AuthDomainSpec extends AnyFlatSpec with Matchers with WorkspaceFixtures wi
implicit override val patienceConfig =
PatienceConfig(timeout = scaled(Span(150, Seconds)), interval = scaled(Span(2, Seconds)))

lazy val projectOwner = UserPool.chooseProjectOwner
lazy val (projectUser, groupOwner) = {
val users = UserPool.chooseStudents(2)
(users(0), users(1))
val bee = PipelineInjector(PipelineInjector.e2eEnv())

lazy val projectOwnerToken = bee.Owners.getUserCredential("hermione").map(_.makeAuthToken).get
lazy val (projectUserToken, groupOwnerToken) = {
val users = bee.chooseStudents(2)
(users(0).makeAuthToken, users(1).makeAuthToken)
}

val billingAccountId: String = ServiceTestConfig.Projects.billingAccountId

"AuthDomains" should "create and access a workspace with an auth domain" in {
val groupOwnerToken = groupOwner.makeAuthToken()

withGroup("ad", List(projectUser.email, projectOwner.email)) { realmGroup =>
withGroup("ad2", List(projectUser.email, projectOwner.email)) { realmGroup2 =>
withGroup("ad3", List(projectUser.email, projectOwner.email)) { realmGroup3 =>
withGroup("ad", List(projectUserToken.userData.email, projectOwnerToken.userData.email)) { realmGroup =>
withGroup("ad2", List(projectUserToken.userData.email, projectOwnerToken.userData.email)) { realmGroup2 =>
withGroup("ad3", List(projectUserToken.userData.email, projectOwnerToken.userData.email)) { realmGroup3 =>
withTemporaryBillingProject(billingAccountId) { projectName =>
withWorkspace(projectName,
"AuthDomains",
Set(realmGroup, realmGroup2, realmGroup3),
List(AclEntry(projectUser.email, WorkspaceAccessLevel.Writer))
List(AclEntry(projectUserToken.userData.email, WorkspaceAccessLevel.Writer))
) { workspace =>
Orchestration.workspaces.setAttributes(projectName, workspace, Map("foo" -> "bar"))(
projectUser.makeAuthToken()
projectUserToken
)
}(projectOwner.makeAuthToken())
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(projectOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}

it should "not create a workspace with a multi-group auth domain if you're not in all groups" in {
val groupOwnerToken = groupOwner.makeAuthToken()

intercept[RestException] {
withGroup("ad", List(projectOwner.email)) { realmGroup =>
withGroup("ad2", List(projectOwner.email)) { realmGroup2 =>
withGroup("ad", List(projectOwnerToken.userData.email)) { realmGroup =>
withGroup("ad2", List(projectOwnerToken.userData.email)) { realmGroup2 =>
withGroup("ad3") { realmGroup3 =>
withTemporaryBillingProject(billingAccountId) { projectName =>
withWorkspace(projectName, "AuthDomains", Set(realmGroup, realmGroup2, realmGroup3)) { _ =>
fail("should not have created workspace")
}(projectOwner.makeAuthToken())
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(projectOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}
}

it should "do the right security when access group membership changes and there is an access" in {
val groupOwnerToken = groupOwner.makeAuthToken()

withGroup("ad", List(projectUser.email, projectOwner.email)) { realmGroup =>
withGroup("ng", List(projectUser.email)) { nestedGroup =>
withGroup("ad", List(projectUserToken.userData.email, projectOwnerToken.userData.email)) { realmGroup =>
withGroup("ng", List(projectUserToken.userData.email)) { nestedGroup =>
val nestedGroupFull = Orchestration.groups.getGroup(nestedGroup)(groupOwnerToken)
withGroup("ag", List(nestedGroupFull.groupEmail)) { accessGroup =>
val accessGroupFull = Orchestration.groups.getGroup(accessGroup)(groupOwnerToken)
val workspaceOwnerToken = projectOwner.makeAuthToken()
val workspaceOwnerToken = projectOwnerToken

// we need a test specific project here because we add one of the groups just created as a writer to the workspace
// which adds the group to the can-compute policy on the project. Deleting the workspace does not remove the group
Expand All @@ -97,21 +97,20 @@ class AuthDomainSpec extends AnyFlatSpec with Matchers with WorkspaceFixtures wi
Set(realmGroup),
List(AclEntry(accessGroupFull.groupEmail, WorkspaceAccessLevel.Writer))
) { workspace =>
val user = projectUser
val userToken = user.makeAuthToken()
val userToken = projectUserToken

// user is in all the right groups, this should work
Orchestration.workspaces.setAttributes(localProject, workspace, Map("foo" -> "bar"))(userToken)

// remove user from nestedGroup and they should lose access
Orchestration.groups.removeUserFromGroup(nestedGroup, user.email, GroupRole.Member)(groupOwnerToken)
Orchestration.groups.removeUserFromGroup(nestedGroup, userToken.userData.email, GroupRole.Member)(groupOwnerToken)
eventually {
intercept[RestException] {
Orchestration.workspaces.setAttributes(localProject, workspace, Map("foo" -> "bar"))(userToken)
}
}
// add user back to nestedGroup and they should have access
Orchestration.groups.addUserToGroup(nestedGroup, user.email, GroupRole.Member)(groupOwnerToken)
Orchestration.groups.addUserToGroup(nestedGroup, userToken.userData.email, GroupRole.Member)(groupOwnerToken)
Orchestration.workspaces.setAttributes(localProject, workspace, Map("foo" -> "bar"))(userToken)

// remove accessGroup from acl and user should lose access
Expand All @@ -129,94 +128,83 @@ class AuthDomainSpec extends AnyFlatSpec with Matchers with WorkspaceFixtures wi
}

}(workspaceOwnerToken)
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}(groupOwnerToken)
}

it should "clone a workspace if the source has a multi-group auth domain and user is in all groups" in {
val authToken = projectOwner.makeAuthToken()
val authToken = projectOwnerToken

withGroup("ad", List(projectUser.email)) { realmGroup =>
withGroup("ad2", List(projectUser.email)) { realmGroup2 =>
withGroup("ad3", List(projectUser.email)) { realmGroup3 =>
withGroup("ad", List(projectUserToken.userData.email)) { realmGroup =>
withGroup("ad2", List(projectUserToken.userData.email)) { realmGroup2 =>
withGroup("ad3", List(projectUserToken.userData.email)) { realmGroup3 =>
val authDomain = Set(realmGroup, realmGroup2, realmGroup3)
withTemporaryBillingProject(billingAccountId, users = List(projectUser.email).some) { projectName =>
withTemporaryBillingProject(billingAccountId, users = List(projectUserToken.userData.email).some) { projectName =>
withWorkspace(projectName,
"AuthDomains",
authDomain,
List(AclEntry(projectUser.email, WorkspaceAccessLevel.Writer))
List(AclEntry(projectUserToken.userData.email, WorkspaceAccessLevel.Writer))
) { workspace =>
val clone = "AuthDomainsClone_" + makeRandomId()
Orchestration.workspaces.clone(projectName, workspace, projectName, clone, authDomain)(
projectUser.makeAuthToken()
)
Orchestration.workspaces.clone(projectName, workspace, projectName, clone, authDomain)(projectUserToken)
try {
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(
projectUser.makeAuthToken()
)

Orchestration.groups.removeUserFromGroup(realmGroup2, projectUser.email, GroupRole.Member)(authToken)
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(projectUserToken)
Orchestration.groups.removeUserFromGroup(realmGroup2, projectUserToken.userData.email, GroupRole.Member)(authToken)
eventually {
intercept[RestException] {
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(
projectUser.makeAuthToken()
)
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(projectUserToken)
}
}
// add users back so the cleanup part of withGroup doesn't have a fit
Orchestration.groups.addUserToGroup(realmGroup2, projectUser.email, GroupRole.Member)(authToken)
Orchestration.groups.addUserToGroup(realmGroup2, projectUserToken.userData.email, GroupRole.Member)(authToken)
} finally
Orchestration.workspaces.delete(projectName, clone)(projectUser.makeAuthToken())
Orchestration.workspaces.delete(projectName, clone)(projectUserToken)
}(authToken)
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(authToken)
}(authToken)
}(authToken)
}

it should "clone a workspace if the user added a group to the source authorization domain" in {
val authToken = projectOwner.makeAuthToken()
val authToken = projectOwnerToken

withGroup("ad", List(projectUser.email)) { realmGroup =>
withGroup("ad2", List(projectUser.email)) { realmGroup2 =>
withGroup("ad3", List(projectUser.email)) { realmGroup3 =>
withGroup("ad", List(projectUserToken.userData.email)) { realmGroup =>
withGroup("ad2", List(projectUserToken.userData.email)) { realmGroup2 =>
withGroup("ad3", List(projectUserToken.userData.email)) { realmGroup3 =>
val authDomain = Set(realmGroup, realmGroup2)
withTemporaryBillingProject(billingAccountId, users = List(projectUser.email).some) { projectName =>
withTemporaryBillingProject(billingAccountId, users = List(projectUserToken.userData.email).some) { projectName =>
withWorkspace(projectName,
"AuthDomains",
authDomain,
List(AclEntry(projectUser.email, WorkspaceAccessLevel.Writer))
List(AclEntry(projectUserToken.userData.email, WorkspaceAccessLevel.Writer))
) { workspace =>
val clone = "AuthDomainsClone_" + makeRandomId()
Orchestration.workspaces.clone(projectName, workspace, projectName, clone, authDomain + realmGroup3)(
projectUser.makeAuthToken()
)
Orchestration.workspaces.clone(projectName, workspace, projectName, clone, authDomain + realmGroup3)(projectUserToken)
try
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(
projectUser.makeAuthToken()
)
Orchestration.workspaces.setAttributes(projectName, clone, Map("foo" -> "bar"))(projectUserToken)
finally
Orchestration.workspaces.delete(projectName, clone)(projectUser.makeAuthToken())
Orchestration.workspaces.delete(projectName, clone)(projectUserToken)

}(authToken)
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(authToken)
}(authToken)
}(authToken)
}

it should "not allow changing a workspace's Realm if it exists" in {
val authToken = projectOwner.makeAuthToken()
val authToken = projectOwnerToken

withGroup("ad", List(projectUser.email)) { realmGroup =>
withGroup("ad2", List(projectUser.email)) { realmGroup2 =>
withGroup("ad", List(projectUserToken.userData.email)) { realmGroup =>
withGroup("ad2", List(projectUserToken.userData.email)) { realmGroup2 =>
withTemporaryBillingProject(billingAccountId) { projectName =>
withWorkspace(projectName,
"AuthDomains",
Set(realmGroup),
List(AclEntry(projectUser.email, WorkspaceAccessLevel.Writer))
List(AclEntry(projectUserToken.userData.email, WorkspaceAccessLevel.Writer))
) { workspace =>
intercept[RestException] {
val clone = "AuthDomainsClone_" + makeRandomId()
Expand All @@ -225,7 +213,7 @@ class AuthDomainSpec extends AnyFlatSpec with Matchers with WorkspaceFixtures wi
Orchestration.workspaces.delete(projectName, workspace)(authToken)
}
}(authToken)
}(projectOwner.makeAuthToken(billingScopes))
}(projectOwnerToken)
}(authToken)
}(authToken)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import com.typesafe.scalalogging.LazyLogging
import org.broadinstitute.dsde.workbench.auth.{AuthToken, AuthTokenScopes}
import org.broadinstitute.dsde.workbench.config.{Credentials, ServiceTestConfig, UserPool}
import org.broadinstitute.dsde.workbench.fixture._
import org.broadinstitute.dsde.test.pipeline._
import org.broadinstitute.dsde.workbench.service.Rawls
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

//noinspection NoTailRecursionAnnotation,RedundantBlock,ScalaUnusedSymbol
@BillingsTest
class BillingApiSpec extends AnyFreeSpec with MethodFixtures with Matchers with TestReporterFixture with LazyLogging {
val bee = PipelineInjector(PipelineInjector.e2eEnv())

val owner: Credentials = UserPool.chooseProjectOwner
implicit val ownerAuthToken: AuthToken = bee.Owners.getUserCredential("hermione").map(_.makeAuthToken).get

"A user with a billing account" - {
"can create a new billing project with v2 api" in {
val owner: Credentials = UserPool.chooseProjectOwner
implicit val ownerAuthToken: AuthToken = owner.makeAuthToken(AuthTokenScopes.billingScopes)
val billingProjectName = "rawls-billingapispecV2-" + makeRandomId()
Rawls.billingV2.createBillingProject(billingProjectName, ServiceTestConfig.Projects.billingAccountId)
val result = Rawls.billingV2.getBillingProject(billingProjectName).toList
Expand Down
Loading
Loading