AConnection: raise Exception when not able to auth

If a login() method just returns False when a login didn't succeed the rest of
the code does not know that a problem occured and then just continues to try to
interact with the target device. Therefore a CantAuthException was introduced
in this commit.

This is a first step to resolve GitHub Issue #99.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
.gitignore: dist/ directory added

contains the data from the setuptools packaging&publishing process.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
AConnection: check first if already authed

One scenario in which an authentication process might fail is when the user is
already authenticated. Therefore before anything else such a test should be
conducted. Here it is implemented in a seperate property which returns True or
False depending on what the shell command "whoami" returns. Only when the
response to "whoami" is the same as the given username in the credentials
attribute then the return value is True, otherwise False.

See GitHub Issue #99.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
AConnection: login reacts to pw prompt

It is possible that as the result of what happened before the login process
actually starts with a password prompt by the connection. This happens for
example, when a is_authenticated request or a _prompt() request is interpreted
as a username by the target device. This is actually what happens in the most
likely scenario of connecting to the device with MONK.

This scenario is treated by checking for it with the previously called
can_auth() and then request a _prompt() when it is likely that the target
device expects a password not a username. This was probably also the reason why
can_auth() tested for user prompt and pw prompt.

Now that I understand the initial idea behind the code I think renaming the
property can_auth to has_user_prompt is better and adding a second one called
has_pw_prompt for the password prompt. Thereby the if-try-if in the login()
method gets easier to read and is less error prone. Now it says that it only
asks for a new prompt when the old one is the password prompt and then only
attempts a login when the given prompt actually is the user prompt.

See GitHub Issue #99.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
conn.py: Debug logging call

Forgot an actual method call.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
conn.py: restructure auth checks

This commit restructures two important methods. One is the login() method from
the Connected state and the other is the _login() method from SerialConn.

The idea before the change was to let Connected do all the checks so that
specific login's connection can focus on what needs to be done to authenticate
the user. Now I think that most of the checks in Connected are actually very
serial specific. For example in an SSH connection there should be a simpler way
to do the authentication via API instead of direct I/O with the device.
Therefore most of the checking that is currently done was moved to SerialConn.

Should support with resolving GitHub Issue #99.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>

For reference. Old commits that influenced SerialConn's _login():
a67f9cb7
ccf81a1a
a67f9cb7
ccf81a1a
1424c353
a67f9cb7
b41467bc

Old commits taht influenced Connected's login():
35ec9832
49c8e41d
9a61f337
49c8e41d
b33936ba
49c8e41d
9a61f337
35ec9832
d4206119
05896498
2d1f363a
cb202fe3
92eb49d7
35ec9832
92eb49d7
6b519e4d
1743aaa7
35ec9832
05896498
35ec9832
fdc27a94
test_conn: Get suite back to working

Through recent debugging endeavours the test suite got some errors. This commit
corrects them. They are mostly small issues where a variable is used in another
way or the credentials attribute of connections become more important. Nothing
serious, though.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>