RESTinstance icon indicating copy to clipboard operation
RESTinstance copied to clipboard

Added HTTP authentication to the API.

Open ot2789 opened this issue 4 years ago • 10 comments

  • Now the requests to HTTP can also contain Basic, Digest and Proxy authentication.

ot2789 avatar May 25 '21 16:05 ot2789

Instead of having four basically identical keywords, would it be more reasonable to have a single keyword Set Client Authentication that takes the type of authentication as an argument and handle passing it on in the keyword itself? E.g

Set Client Authentication | basic | username | password
Set Client Authentication | digest | username | password
Set Client Authentication | | | 

asimell avatar May 26 '21 05:05 asimell

Instead of having four basically identical keywords, would it be more reasonable to have a single keyword Set Client Authentication that takes the type of authentication as an argument and handle passing it on in the keyword itself? E.g

Set Client Authentication | basic | username | password
Set Client Authentication | digest | username | password
Set Client Authentication | | | 

Yes. I can do that it is not a problem. Two questions however.

  1. Is it fine if the first parameter is a string and the check is done through string comparison (case insensitive).
  2. In the situation in which a user wants to clear the authentication. Would the value ${NONE} be used or can the user call this keyword without any arguments?

In the code I also replaced deepcopy with copy because if the user adds the Digest authentication the deepcopy function cannot get the treading local structurest that are used in HTTPDigestAuth. I don't know if this is the best solution to this problem.

ot2789 avatar May 26 '21 07:05 ot2789

  1. I think case insensitive string comparison should work just fine as long as the supported values are documented.
  2. Using ${NONE} would probably make more sense than no arguments at all. This would mean that the first argument is mandatory (type of authentication) and the username and password are optional.

asimell avatar May 26 '21 07:05 asimell

I updated the keywords according to your comment. Let me know if you have other ideas.

ot2789 avatar May 26 '21 11:05 ot2789

Could you also create tests to test the new functionality? Place the tests in the atest directory. Also, by looking at headers.robot it looks like the behaviour of this keyword is already somewhat supported just by using headers.

Could you also open this PR to eficode/restinstance? While we're waiting for repository transfer (ping @asyrjasalo) we're handling PRs by first merging them to Eficode fork and then creating a combined PR here with the next release.

asimell avatar May 26 '21 12:05 asimell

It is true that headers.robot can fix the Basic authentication. But it doesn't fix the Digest which is dynamic on connection. I will add the test then continue with the PR on the other repository after you confirm here that we're good here.

ot2789 avatar May 26 '21 13:05 ot2789

@ot2789 LGTM. Can you create a PR to Eficode/RESTinstance (I'll keep this one open as well). We'll merge this first there and then come back here with full release candidate.

asimell avatar May 28 '21 11:05 asimell

@asimell Ok. I'll create a PR there as well. Can you tell if there is a way to install the release that contains this PR through pip3? Edit: Done, https://github.com/eficode/RESTinstance/pull/8

ot2789 avatar May 28 '21 12:05 ot2789

@ot2789 We will make a separate PR here that we'll merge here and release that to PyPI. We won't make the release through Eficode fork. Unfortunately, @asyrjasalo hasn't transferred this repo to Eficode org, even though he asked us to maintain this library. We've got our CI in place and full access rights in Eficode org, so this is how we roll for now.

asimell avatar May 28 '21 13:05 asimell

@asimell It is ok. I don't need to use the Eficode fork for updating. Just interested in installing it with pip3. So when this is approved, checked and merged. Let me know how I can install it. I expect to be something like pip3 install RESTinstance==1.x.xrc1 or something among those lines.

ot2789 avatar May 31 '21 14:05 ot2789