Skip to content

Commit

Permalink
[ControlPlane] bring controlplane tests back to life
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbondar92 authored and assaf758 committed Sep 13, 2021
1 parent 85e858b commit bc0a46a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions pkg/controlplane/test/controlplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,37 @@ func (suite *githubClientSuite) SetupSuite() {

// create a unique user for the tests
ts := time.Now().Unix()
username := fmt.Sprintf("testuser-%d", ts)
createUserInput := v3ioc.CreateUserInput{}
createUserInput.Ctx = suite.ctx
createUserInput.FirstName = fmt.Sprintf("Test-%d", ts)
createUserInput.LastName = fmt.Sprintf("User-%d", ts)
createUserInput.Username = username
createUserInput.Password = fmt.Sprintf("testpasswd-%d", ts)
createUserInput.Username = fmt.Sprintf("testuser-%d", ts)
createUserInput.Password = fmt.Sprintf("Testpasswd-%d!", ts)
createUserInput.Email = fmt.Sprintf("testuser-%[email protected]", ts)
createUserInput.Description = "A user created from tests"
createUserInput.AssignedPolicies = []string{"Security Admin", "Data", "Application Admin", "Function Admin"}
createUserInput.AssignedPolicies = []string{"Security Admin", "Data", "Application Admin"}

// create a user with security session
createUserOutput, err := session.CreateUserSync(&createUserInput)
suite.Require().NoError(err)
suite.Require().NotNil(createUserOutput.ID)
suite.userID = createUserOutput.ID

// create new user's session
newSessionInput = v3ioc.NewSessionInput{}
newSessionInput.Username = createUserInput.Username
newSessionInput.Password = createUserInput.Password
newSessionInput.Endpoints = []string{controlplaneURL}

newUserSession, err := v3iochttp.NewSession(suite.logger, &newSessionInput)
suite.Require().NoError(err, fmt.Sprintf("\nInput: %v\n", newSessionInput))

getRunningUserAttributesInput := v3ioc.GetRunningUserAttributesInput{}
getRunningUserAttributesInput.Ctx = suite.ctx

getRunningUserAttributesOutput, err := session.GetRunningUserAttributesSync(&getRunningUserAttributesInput)
getRunningUserAttributesOutput, err := newUserSession.GetRunningUserAttributesSync(&getRunningUserAttributesInput)
suite.Require().NoError(err)
suite.Require().Equal(getRunningUserAttributesOutput.Username, username)
suite.Require().Equal(getRunningUserAttributesOutput.Username, createUserInput.Username)

// create a session with that user
newSessionInput.Username = createUserInput.Username
Expand All @@ -83,7 +91,7 @@ func (suite *githubClientSuite) TearDownSuite() {
}

func (suite *githubClientSuite) SetupTest() {
suite.ctx = context.WithValue(nil, "RequestID", "test-0")
suite.ctx = context.WithValue(context.TODO(), "RequestID", "test-0")
}

func (suite *githubClientSuite) TestCreateContainerStringID() {
Expand Down

0 comments on commit bc0a46a

Please sign in to comment.