fix(http): Ensures users are created with an active status

pull/15295/head
Deary Hudson 2019-09-27 13:43:19 -05:00 committed by Deary Hudson
parent 9f5390e449
commit bd7c4dad8f
6 changed files with 120 additions and 74 deletions

View File

@ -1,3 +1,7 @@
## v2.0.0-alpha.19 [unreleased]
### Bug Fixes
1. [15295](https://github.com/influxdata/influxdb/pull/15295): Ensures users are created with an active status
## v2.0.0-alpha.18 [2019-09-26]
### Features

View File

@ -7,6 +7,7 @@ import (
"time"
bolt "github.com/coreos/bbolt"
influxdb "github.com/influxdata/influxdb"
platform "github.com/influxdata/influxdb"
platformcontext "github.com/influxdata/influxdb/context"
)
@ -226,6 +227,7 @@ func (c *Client) CreateUser(ctx context.Context, u *platform.User) error {
}
u.ID = c.IDGenerator.ID()
u.Status = influxdb.Active
if err := c.appendUserEventToLog(ctx, tx, u.ID, userCreatedEvent); err != nil {
return err

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/influxdata/influxdb"
platform "github.com/influxdata/influxdb"
)
@ -157,6 +158,7 @@ func (s *Service) CreateUser(ctx context.Context, u *platform.User) error {
}
}
u.ID = s.IDGenerator.ID()
u.Status = influxdb.Active
s.PutUser(ctx, u)
return nil
}

View File

@ -236,6 +236,7 @@ func (s *Service) createUser(ctx context.Context, tx Tx, u *influxdb.User) error
}
u.ID = s.IDGenerator.ID()
u.Status = influxdb.Active
if err := s.appendUserEventToLog(ctx, tx, u.ID, userCreatedEvent); err != nil {
return err
}

View File

@ -151,8 +151,9 @@ func Generate(
password: "password1",
results: &platform.OnboardingResults{
User: &platform.User{
ID: MustIDBase16(oneID),
Name: "admin",
ID: MustIDBase16(oneID),
Name: "admin",
Status: platform.Active,
},
Org: &platform.Organization{
ID: MustIDBase16(twoID),

View File

@ -161,8 +161,9 @@ func CreateUser(
},
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "user1",
ID: MustIDBase16(userOneID),
Name: "user1",
Status: platform.Active,
},
},
},
@ -174,8 +175,9 @@ func CreateUser(
wants: wants{
users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "user1",
ID: MustIDBase16(userOneID),
Name: "user1",
Status: platform.Active,
},
},
err: &platform.Error{
@ -235,12 +237,14 @@ func FindUserByID(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "user1",
ID: MustIDBase16(userOneID),
Name: "user1",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "user2",
ID: MustIDBase16(userTwoID),
Name: "user2",
Status: platform.Active,
},
},
},
@ -249,8 +253,9 @@ func FindUserByID(
},
wants: wants{
user: &platform.User{
ID: MustIDBase16(userTwoID),
Name: "user2",
ID: MustIDBase16(userTwoID),
Name: "user2",
Status: platform.Active,
},
},
},
@ -259,12 +264,14 @@ func FindUserByID(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "user1",
ID: MustIDBase16(userOneID),
Name: "user1",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "user2",
ID: MustIDBase16(userTwoID),
Name: "user2",
Status: platform.Active,
},
},
},
@ -322,12 +329,14 @@ func FindUsers(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -335,12 +344,14 @@ func FindUsers(
wants: wants{
users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -350,12 +361,14 @@ func FindUsers(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -365,8 +378,9 @@ func FindUsers(
wants: wants{
users: []*platform.User{
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -376,12 +390,14 @@ func FindUsers(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -391,8 +407,9 @@ func FindUsers(
wants: wants{
users: []*platform.User{
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -497,12 +514,14 @@ func DeleteUser(
fields: UserFields{
Users: []*platform.User{
{
Name: "orgA",
ID: MustIDBase16(userOneID),
Name: "orgA",
ID: MustIDBase16(userOneID),
Status: platform.Active,
},
{
Name: "orgB",
ID: MustIDBase16(userTwoID),
Name: "orgB",
ID: MustIDBase16(userTwoID),
Status: platform.Active,
},
},
},
@ -512,8 +531,9 @@ func DeleteUser(
wants: wants{
users: []*platform.User{
{
Name: "orgB",
ID: MustIDBase16(userTwoID),
Name: "orgB",
ID: MustIDBase16(userTwoID),
Status: platform.Active,
},
},
},
@ -523,12 +543,14 @@ func DeleteUser(
fields: UserFields{
Users: []*platform.User{
{
Name: "orgA",
ID: MustIDBase16(userOneID),
Name: "orgA",
ID: MustIDBase16(userOneID),
Status: platform.Active,
},
{
Name: "orgB",
ID: MustIDBase16(userTwoID),
Name: "orgB",
ID: MustIDBase16(userTwoID),
Status: platform.Active,
},
},
},
@ -543,12 +565,14 @@ func DeleteUser(
},
users: []*platform.User{
{
Name: "orgA",
ID: MustIDBase16(userOneID),
Name: "orgA",
ID: MustIDBase16(userOneID),
Status: platform.Active,
},
{
Name: "orgB",
ID: MustIDBase16(userTwoID),
Name: "orgB",
ID: MustIDBase16(userTwoID),
Status: platform.Active,
},
},
},
@ -600,12 +624,14 @@ func FindUser(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -616,8 +642,9 @@ func FindUser(
},
wants: wants{
user: &platform.User{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
},
},
@ -626,12 +653,14 @@ func FindUser(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -642,8 +671,9 @@ func FindUser(
},
wants: wants{
user: &platform.User{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
},
},
@ -688,12 +718,14 @@ func FindUser(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "xyz",
ID: MustIDBase16(userTwoID),
Name: "xyz",
Status: platform.Active,
},
},
},
@ -705,8 +737,9 @@ func FindUser(
},
wants: wants{
user: &platform.User{
ID: MustIDBase16(userOneID),
Name: "abc",
ID: MustIDBase16(userOneID),
Name: "abc",
Status: platform.Active,
},
},
},
@ -798,12 +831,14 @@ func UpdateUser(
fields: UserFields{
Users: []*platform.User{
{
ID: MustIDBase16(userOneID),
Name: "user1",
ID: MustIDBase16(userOneID),
Name: "user1",
Status: platform.Active,
},
{
ID: MustIDBase16(userTwoID),
Name: "user2",
ID: MustIDBase16(userTwoID),
Name: "user2",
Status: platform.Active,
},
},
},
@ -813,8 +848,9 @@ func UpdateUser(
},
wants: wants{
user: &platform.User{
ID: MustIDBase16(userOneID),
Name: "changed",
ID: MustIDBase16(userOneID),
Name: "changed",
Status: platform.Active,
},
},
},