Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

AConnection.can_login(): Should only check for login prompt #104

Closed
erikbgithub opened this issue Mar 5, 2014 · 0 comments
Closed

AConnection.can_login(): Should only check for login prompt #104

erikbgithub opened this issue Mar 5, 2014 · 0 comments
Assignees
Labels

Comments

@erikbgithub
Copy link
Contributor

Problem

Currently can_login() checks whether it finds login or password prompt, but a login can actually only start if there is the login prompt.

Solution

Only check for login prompt.

Notes

  • would be great if it is a property not function
@erikbgithub erikbgithub added this to the v0.1.6 - Docs milestone Mar 5, 2014
@erikbgithub erikbgithub added the bug label Mar 5, 2014
erikbgithub added a commit that referenced this issue Mar 5, 2014
Until now the can_login Method checked for both password and login prompt. This
seems unreasonable. Either the content or the method's name had to be changed.
For now a change of content was assumed the better solution, because the method
was used in several places already.

Also for usability the method was transformed into a property.

See GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue Mar 5, 2014
At first _prompt() raised an EmptyResponseException always when an empty string
was the result of its _cmd() call. But that is actually bad in the most common
scenario in which _prompt() basically asks for a current prompt string.
Updating the last_prompt string does not result in any output. Therefore
_prompt() raised an exception in the case where everything worked as expected.

The problem was resolved by also checking the last_prompt attribute. It gets
deleted before the _cmd() call and checked for existance after the call.
Therefore it must have been set in the middle. Only if that didn't happen and
no output was generated then an exception is raised.

FYI: The EmptyResponseException is important for the Disconnected state to
verify if a switch to the Connected state is possible. If you ask for a new
prompt and recieve absolutely nothing back than it is likely that the device is
not running or not connected to the test host properly. Therefore catching an
EmptyResponseException results in not switching to the Connected state.

See GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue Mar 5, 2014
In the previous commit to the same GitHub Issue #104 a check for last_prompt
was added to AConnection's _prompt() method. Therefore the test connections
also need to provide one if one is requested.

See GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue Mar 5, 2014
The message that is actually sent to the device might be transformed in many
ways from what is actually entered into the public cmd() method by the user. To
better see what actually gets transmitted between test host and target device a
logging message was added.

See GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue Mar 5, 2014
Authenticating a user requires actually two steps, sending the username and
then sending the password. While debugging it was not clear whether one of
these steps or something in the middle might result in a buggy behaviour. It
was not the case, but to clear up the code helped evaluating the situation
better.

See GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue Mar 6, 2014
In commit a827b14 _prompt() got the additional check for the last_prompt
attribute. The goal was to make sure an EmptyResponseException is not just
raised when the _cmd() call does not return any output because that
also happens when the prompt is updated as expected. The new if should only
result in the exception path if last_prompt and output where empty.

I completely forgot, though, that I delete last_prompt. So if it is not set it
simply does not exist and the Exception shown to the user will be an
AttributeError.

Here I correct this by checking for the existance of the last_prompt attribute
first. Only then the exception is raised.

The SilentConnection loses the line where it creates an empty last_prompt
attribute to reflect the change of understanding in the test suite.

This is a late additional commit to GitHub Issue #104.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
@erikbgithub erikbgithub self-assigned this Mar 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant