App-Dochazka-CLI
view release on metacpan or search on metacpan
lib/App/Dochazka/CLI/Testers.pm view on Meta::CPAN
Let us see the state of a freshly created employee:
Dochazka(2016-01-27) root ADMIN> emp=george profile
Full name: King George III
Nick: george
Email: (not set)
Secondary ID: (not set)
Dochazka EID: 5
Reports to: (not set)
This only tells us the state of the employee object. Most objects in the
Dochazka database are associated with an employee via the Dochazka EID
value (5 in this example). We can get the same information by typing:
Dochazka(2016-01-27) root ADMIN> eid=5 profile
Full name: King George III
Nick: george
Email: (not set)
Secondary ID: (not set)
Dochazka EID: 5
Reports to: (not set)
=head2 Log in as george
Now, exit the CLI and run it again as C<george>, our new employee.
$ dochazka-cli
...
Username: george
Authenticating to server at http://localhost:5000 as user george
Password:
MREST_CLI_UNAUTHORIZED (ERR) MREST_CLI_UNAUTHORIZED
Response: '401 Unauthorized'
This happens because there is no password set for C<george>.
=head2 Assign george a password
Fortunately, Dochazka admins can assign any password to any user. This
capability may or may not be useful, depending on whether LDAP
authentication is active at the site. In our current testing scenario, LDAP
authentication is disabled, so the password is taken from the Dochazka
database. So, let's give george a password:
$ dochazka-cli -u root -p immutable
...
Dochazka(2016-01-27) root ADMIN> emp=george password
It is important that the new password really be what you intended.
Therefore, we are going to ask you to enter the desired password
twice, so you have a chance to double-check.
New password : <type george>
New password again: <type george again>
Password changed
Now you can log in with credentials C<george/george>:
$ dochazka-cli -u george -p george
...
Authenticating to server at http://localhost:5000 as user george
Server is alive
Dochazka(2016-01-27) george PASSERBY>
=head1 SESSION 3: EMPLOYEE PRIVILEGE HISTORY
Before you do anything, L<make sure the server is running|"Start the server">.
=head2 Verify state
If you are continuing from Session 2, you can skip this step.
If you are starting over (or from scratch), run the following script to
bring your database into the proper state:
#!/bin/sh
cat <<EOF | dochazka-cli -u root -p immutable
PUT employee nick george { "fullname" : "King George III", "salt" : "a054d158a23c3a07ad0163107ad72a8649597d71", "passhash" : "5cf2c3a23de9db43d2d846172966150e9197717ecd0304bafef3f23fc159df942021dd3aec7b4dbcde87d8a44c1bd905bbba3862989065d012bb46a1...
EOF
=head2 Log in as the test employee
This just demonstrates that the test employee can log in.
$ dochazka-cli -u george -p george
...
Authenticating to server at http://localhost:5000 as user george
Server is alive
Dochazka(2016-01-27) george PASSERBY>
=head2 Concepts (Dochazka prompt, employee priv levels)
Let's review the information presented in the prompt:
=over
=item Prompt date in parentheses (defaults to current date)
=item Logged-in employee (george)
=item Privilege level of logged-in employee (passerby)
=back
The privilege level deserves closer attention. Dochazka has four privilege
levels:
=over
=item passerby
( run in 2.248 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )