feedhenry / fh-fhc

FeedHenry CLI, the Command Line Interface to FeedHenry
Other
26 stars 66 forks source link

FH-3751 - Change the cmd fhc admin-users to follow the V3 standard an… #403

Closed camilamacedo86 closed 7 years ago

camilamacedo86 commented 7 years ago

…d add unit tests

JIRA: https://issues.jboss.org/browse/FH-3751

Changes

Steps to Verify

Local Test

screen shot 2017-08-17 at 2 40 24 pm screen shot 2017-08-17 at 2 40 30 pm screen shot 2017-08-17 at 2 42 41 pm
Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users delete conor@example.com
User deleted successfully.
Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users delete spoole+test@redhat.com --json
{
  "fields": {
    "activated": true,
    "authpolicies": [],
    "blacklisted": false,
    "businessObject": "cluster/reseller/customer/user",
    "customerRoles": [],
    "defaultDomain": "",
    "email": "spoole+test@redhat.com",
    "enabled": true,
    "fhaaa.authorisation.enabled": true,
    "groups": [],
    "hierarchy": {
      "cluster": "sam1-core",
      "cluster/reseller": "t-ub7fDklyz-gwe3oL5DPupH",
      "cluster/reseller/customer": "44WKNggefW9N0ggTtqN2SFuF",
      "cluster/reseller/customer/user": "xkqoe77zpluhzgyry3gqfne2"
    },
    "lastLogin": "2016-09-08 18:48:52",
    "name": "Shannon",
    "parentEntity": "TenantImpl:44WKNggefW9N0ggTtqN2SFuF:FeedHenry Support~support",
    "permissions": [],
    "prefs": {
      "accountType": "enterprise",
      "studio.version": "beta",
      "viewType": "grid"
    },
    "reseller": "t-ub7fDklyz-gwe3oL5DPupH",
    "resellerRoles": [],
    "roles": [],
    "storeItemGroups": [],
    "sub": "kajkiik4rxhqnnjffciyzzrn",
    "subscriber": "kajkiik4rxhqnnjffciyzzrn",
    "sysCreated": "2016-05-10 14:49:55:017",
    "sysGroupFlags": 65567,
    "sysGroupList": "",
    "sysModified": "2016-12-01 14:19:08:983",
    "sysShardPoint": 3131105919,
    "sysVersion": 98,
    "teams": [],
    "tenant": "44WKNggefW9N0ggTtqN2SFuF",
    "username": "spoole+test@redhat.com"
  },
  "guid": "xkqoe77zpluhzgyry3gqfne2",
  "status": "ok",
  "type": "ten_User"
}
Camilas-MacBook-Pro:fh-fhc cmacedo$ 

Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users create newuser newuser@gmail.com User created successfully. Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users create newuser newuser@gmail.com --json fhc ERR! Error creating user: User with ID already exists fhc Command executed with error Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users create newuser2 newuser2@gmail.com --json { "status": "ok", "username": "newuser2" } Camilas-MacBook-Pro:fh-fhc cmacedo$

- ` ./bin/fhc.js admin users update <username> <newemail> `

<img width="799" alt="screen shot 2017-08-17 at 3 15 42 pm" src="https://user-images.githubusercontent.com/7708031/29416733-f5b3d984-835e-11e7-8973-fc8c56ba5974.png">

- ` ./bin/fhc.js admin users update <username> <newemail> --json`

<img width="881" alt="screen shot 2017-08-17 at 3 16 18 pm" src="https://user-images.githubusercontent.com/7708031/29416764-0f51cedc-835f-11e7-8c55-c07c0dd1c489.png">

- `./bin/fhc.js admin users changeroles --username=<username> --roles=<roles>`

<img width="931" alt="screen shot 2017-08-19 at 7 51 09 pm" src="https://user-images.githubusercontent.com/7708031/29489379-c741b264-8517-11e7-8530-e439d2f1dd9e.png">

- `./bin/fhc.js admin users changeauthpolicies --username=<username> --authpolicies=<authpolicies>`

<img width="1079" alt="screen shot 2017-08-19 at 7 53 52 pm" src="https://user-images.githubusercontent.com/7708031/29489398-36865404-8518-11e7-9b43-fdc684e77e4b.png">

- `./bin/fhc.js admin users import <file>`

Before the change:

Camilas-MacBook-Pro:fh-fhc cmacedo$ fhc admin users import test.csv fhc ERR! Error: Command not found: users fhc ERR! fhc ERR! System Darwin 15.6.0 fhc ERR! command "/Users/cmacedo/.nvm/versions/node/v4.4.3/bin/node" "/Users/cmacedo/.nvm/versions/node/v4.4.3/bin/fhc" "admin" "users" "import" "test.csv" fhc Command executed with error Camilas-MacBook-Pro:fh-fhc cmacedo$ fhc admin-users import test.csv fhc ERR! [ { action: {}, fhc ERR! cacheKey: '1a1fc4cfc2cb52f0c099a0b633e4d481', fhc ERR! error: 'Failed to parse CSV file. Error: Wrong data record format. Only 2 columns found.', fhc ERR! log: [ 'Failed to parse CSV file. Error: Wrong data record format. Only 2 columns found.' ], fhc ERR! status: 'error' } ] fhc Command executed with error

After the change:

Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users import test.csv fhc ERR! [ { action: {}, fhc ERR! cacheKey: '6153e2dc94ec9f1c374fddfc98b0ce73', fhc ERR! error: 'Failed to parse CSV file. Error: Wrong data record format. Only 2 columns found.', fhc ERR! log: [ 'Failed to parse CSV file. Error: Wrong data record format. Only 2 columns found.' ], fhc ERR! status: 'error' } ] fhc Command executed with error Camilas-MacBook-Pro:fh-fhc cmacedo$

- With empty file.

Camilas-MacBook-Pro:fh-fhc cmacedo$ ./bin/fhc.js admin users import ~/Desktop/test.csv [{ "action": {}, "cacheKey": "bae97e1933411517819893f4e6a3ca23", "error": "", "log": [ "Going to import 0 users", "Finished importing users" ], "progress": 100, "status": "complete" }] Camilas-MacBook-Pro:fh-fhc cmacedo$



- ` ./bin/fhc.js admin users disable <username>`

<img width="896" alt="screen shot 2017-08-20 at 10 19 29 am" src="https://user-images.githubusercontent.com/7708031/29493583-211bc1d4-8591-11e7-99cb-093ddc8d41fb.png">

- ` ./bin/fhc.js admin users enable <username>`

<img width="904" alt="screen shot 2017-08-20 at 10 19 33 am" src="https://user-images.githubusercontent.com/7708031/29493584-254be41e-8591-11e7-959d-4a13a587ff96.png">