Skip to content

Commit

Permalink
Add Active and S3CanonicalUserID to UserProperties (#88)
Browse files Browse the repository at this point in the history
* Add `Active` to `UserProperties`

The field was forgotten in the API's swagger document.
The API team confirmed that the field can be relied on, though.
A bug was filed regarding the incomplete swagger doc.

* Add S3CanonicalUserID to tests

* Make Active a pointer

Contract owners can use this field to activate or deactivate a user.
So this field can be part of PUT and PATCH but omitempty would lead to
`false` not being sent.

* Reflect changes in the README
  • Loading branch information
piepmatz committed Dec 2, 2020
1 parent 0721cc9 commit 3a396aa
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 50 deletions.
98 changes: 55 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ Retrieve details about a specific user including what groups and resources the u
The following table describes the request arguments:
| Name | Required | Type | Description |
| ------ | -------- | ------ | ---------------------------------------------------------- |
| ------ | :------: | ------ | ---------------------------------------------------------- |
| userid | **yes** | string | The ID of the specific user to retrieve information about. |
```
Expand All @@ -2083,64 +2083,76 @@ Creates a new user under a particular contract.
The following table describes the request arguments:
| Name | Required | Type | Description |
| ---- | -------- | ---- | ---------------------------------------- |
| user | **yes** | User | See [User Object](#user-resource-object) |
| Name | Required | Type | Description |
| ---- | :------: | ----------------------------- | --------------- |
| user | **yes** | [User](#user-resource-object) | The user data. |
Build the `User` resource object:
var user = User{
Properties: &UserProperties{
Firstname: "John",
Lastname: "Doe",
Email: email,
Password: "abc123-321CBA",
Administrator: false,
ForceSecAuth: false,
SecAuthActive: false,
},
}
```go
user := User{
Properties: &UserProperties{
Firstname: "John",
Lastname: "Doe",
Email: "test@go.com",
Password: "abc123-321CBA",
Administrator: false,
ForceSecAuth: false,
SecAuthActive: false,
},
}
```
Pass the object to `CreateUser`:
```
CreateUser(user User)
```go
CreateUser(user)
```
#### User Resource Object
| Name | Required | Type | Description |
| ------------- | :------: | ---- | ------------------------------------------------------------------------- |
| Firstname | **yes** | bool | The first name of the user. |
| Lastname | **yes** | bool | The last name of the user. |
| Email | **yes** | bool | The e-mail address of the user. |
| Password | **yes** | bool | A password for the user. |
| Administrator | no | bool | Indicates if the user has administrative rights. |
| ForceSecAuth | no | bool | Indicates if secure (two-factor) authentication was enabled for the user. |
| SecAuthActive | no | bool | Indicates if secure (two-factor) authentication is enabled for the user. |
| Name | Required | Type | Description |
| ----------------- | :-----: | ------ | ------------------------------------------------------------------------- |
| Firstname | **yes** | string | The first name of the user. |
| Lastname | **yes** | string | The last name of the user. |
| Email | **yes** | string | The e-mail address of the user. |
| Password | **yes** | string | A password for the user. |
| Administrator | no | bool | Indicates if the user has administrative rights. |
| ForceSecAuth | no | bool | Indicates if secure (two-factor) authentication was enabled for the user. |
| SecAuthActive | no | bool | Indicates if secure (two-factor) authentication is enabled for the user. |
| Active | no | *bool | Indicates if the user is active (true) or disabled (false). |
| S3CanonicalUserID | no | string | The user's S3 ID. |
---
#### Update a User
Update details about a specific user including their privileges.
Update details about a specific user including its privileges.
The following table describes the request arguments:
| Name | Required | Type | Description |
| ------ | -------- | ------ | -------------------------------------- |
| userid | **Yes** | string | The ID of the specific user to update. |
| Name | Required | Type | Description |
| ------ | :------: | ----------------------------- | -------------------------------------- |
| userid | **yes** | string | The ID of the specific user to update. |
| user | **yes** | [User](#user-resource-object) | The user data. |
```go
t := true
user := User{
Properties: &UserProperties{
Firstname: "go sdk",
Lastname: "newName",
Email: "test@go.com",
Administrator: false,
ForceSecAuth: false,
SecAuthActive: false,
Active: &t,
},
}
```
user := UserProperties{
Firstname: "go sdk ",
Lastname: newName,
Email: "test@go.com",
Password: "abc123-321CBA",
Administrator: false,
ForceSecAuth: false,
SecAuthActive: false,
}
Pass the object to `UpdateUser`:
```go
UpdateUser(userid, user)
```
Expand All @@ -2153,10 +2165,10 @@ Blacklists the user, disabling them. The user is not completely purged, therefor
The following table describes the request arguments:
| Name | Type | Description | Required |
| ------ | ------- | ----------- | -------------------------------------- |
| userid | **Yes** | string | The ID of the specific user to update. |
| ------ | :-----: | ----------- | -------------------------------------- |
| userid | **yes** | string | The ID of the specific user to delete. |
```
```go
DeleteUser(userid)
```
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/usermanagment_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func TestCreateUser(t *testing.T) {
assert.Equal(t, user.Properties.Firstname, "John")
assert.Equal(t, user.Properties.Lastname, "Doe")
assert.Equal(t, user.Properties.Email, email)
if assert.NotNil(t, user.Properties.Active) {
assert.True(t, *user.Properties.Active)
}
assert.Equal(t, user.Properties.Administrator, false)
assert.NotEmpty(t, user.Properties.S3CanonicalUserID)
}

func TestCreateUserFailure(t *testing.T) {
Expand Down Expand Up @@ -121,8 +125,12 @@ func TestGetUser(t *testing.T) {
assert.Equal(t, resp.Properties.Firstname, "John")
assert.Equal(t, resp.Properties.Lastname, "Doe")
assert.Equal(t, resp.Properties.Email, email)
if assert.NotNil(t, resp.Properties.Active) {
assert.True(t, *resp.Properties.Active)
}
assert.Equal(t, resp.Properties.Administrator, false)
assert.Equal(t, resp.PBType, "user")
assert.NotEmpty(t, resp.Properties.S3CanonicalUserID)
}

func TestUpdateUser(t *testing.T) {
Expand Down
16 changes: 9 additions & 7 deletions usermanagment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ type User struct {

// UserProperties object
type UserProperties struct {
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Administrator bool `json:"administrator,omitempty"`
ForceSecAuth bool `json:"forceSecAuth,omitempty"`
SecAuthActive bool `json:"secAuthActive,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Administrator bool `json:"administrator,omitempty"`
ForceSecAuth bool `json:"forceSecAuth,omitempty"`
SecAuthActive bool `json:"secAuthActive,omitempty"`
Active *bool `json:"active,omitempty"`
S3CanonicalUserID string `json:"s3CanonicalUserId,omitempty"`
}

// UserEntities object
Expand Down

0 comments on commit 3a396aa

Please sign in to comment.