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

TPT 2123: Add missing fields to account_users #336

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions account_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (

// User represents a User object
type User struct {
Username string `json:"username"`
Email string `json:"email"`
Restricted bool `json:"restricted"`
TFAEnabled bool `json:"tfa_enabled"`
SSHKeys []string `json:"ssh_keys"`
Username string `json:"username"`
Email string `json:"email"`
Restricted bool `json:"restricted"`
TFAEnabled bool `json:"tfa_enabled"`
SSHKeys []string `json:"ssh_keys"`
PasswordCreated string `json:"password_created"`
VerifiedPhoneNumber string `json:"verified_phone_number"`
}

// UserCreateOptions fields are those accepted by CreateUser
Expand Down
18 changes: 18 additions & 0 deletions test/integration/account_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ func TestUser_Get(t *testing.T) {
if !user.Restricted {
t.Error("expected user to be restricted")
}
if user.TFAEnabled {
t.Error("expected TFA is disabled")
}
if user.PasswordCreated != "" {
t.Error("expected password is not set")
}
if user.VerifiedPhoneNumber != "" {
t.Error("expected phone number is not set")
}
}

func TestUser_Update(t *testing.T) {
Expand Down Expand Up @@ -135,6 +144,15 @@ func TestUsers_List(t *testing.T) {
if newUser.Restricted {
t.Error("expected user to not be restricted")
}
if newUser.TFAEnabled {
t.Error("expected TFA is disabled")
}
if newUser.PasswordCreated != "" {
t.Error("expected password is not set")
}
if newUser.VerifiedPhoneNumber != "" {
t.Error("expected phone number is not set")
}
}

func createUser(t *testing.T, client *linodego.Client, userModifiers ...userModifier) (*User, func()) {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/fixtures/TestUser_Get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"username": "linodegotest-getuser", "email": "[email protected]",
"restricted": true, "ssh_keys": [], "tfa_enabled": false, "verified_phone_number":
null}'
null, "password_created": null}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -31,7 +31,7 @@ interactions:
Cache-Control:
- private, max-age=60, s-maxage=60
Content-Length:
- "170"
- "196"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand Down Expand Up @@ -73,7 +73,7 @@ interactions:
response:
body: '{"username": "linodegotest-getuser", "email": "[email protected]",
"restricted": true, "ssh_keys": [], "tfa_enabled": false, "verified_phone_number":
null}'
null, "password_created": null}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -89,7 +89,7 @@ interactions:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Content-Length:
- "170"
- "196"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand Down
13 changes: 6 additions & 7 deletions test/integration/fixtures/TestUsers_List.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interactions:
response:
body: '{"username": "linodegotest-listuser", "email": "[email protected]",
"restricted": false, "ssh_keys": [], "tfa_enabled": false, "verified_phone_number":
null}'
null, "password_created": null}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -31,7 +31,7 @@ interactions:
Cache-Control:
- private, max-age=60, s-maxage=60
Content-Length:
- "173"
- "199"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand Down Expand Up @@ -71,12 +71,11 @@ interactions:
url: https://api.linode.com/v4beta/account/users
method: GET
response:
body: '{"data": [{"username": "lgarber-dev", "email": "REDACTED", "restricted":
false, "ssh_keys": ["tf_test_authorized_keys", "main", "tf_test_authorized_keys",
"dev-server-rsa", "tf_test_authorized_keys"], "tfa_enabled": true, "verified_phone_number":
body: '{"data": [{"username": "ychen123", "email": "[email protected]", "restricted":
false, "ssh_keys": [], "tfa_enabled": true, "verified_phone_number": null, "password_created":
null}, {"username": "linodegotest-listuser", "email": "[email protected]",
"restricted": false, "ssh_keys": [], "tfa_enabled": false, "verified_phone_number":
null}], "page": 1, "pages": 1, "results": 2}'
null, "password_created": null}], "page": 1, "pages": 1, "results": 2}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -92,7 +91,7 @@ interactions:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Content-Length:
- "476"
- "419"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand Down