asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://asyrjasalo.github.io/RESTinstance
GNU Lesser General Public License v3.0
204 stars 84 forks source link

RESTinstance 1.2.0: Headers are not "set", only "updated" #125

Closed leonpros closed 2 years ago

leonpros commented 2 years ago

When setting a header for the first time, it will not be removed for the second time i try to set new headers. i.e: create a login request that does not have access token add access token to headers try to create a new login request without access token.

expected: no access token header in request

actual: access token request exists (causes request to fail).

Does not happen on RESTinstance 1.1.0 and below

asimell commented 2 years ago

What keywords are you calling?

leonpros commented 2 years ago

What keywords are you calling?

Tried in 2 different methods:

By using POST|GET|PUT|DELETE keywords: Send Post Request | [Arguments] | ${endpoint}= | ${headers}= | ${body}=null | POST | endpoint=${endpoint} | body=${body} | headers=${headers}

And by using Set Headers keyword:

Send Post Request | [Arguments] | ${endpoint}= | ${headers}= | ${body}=null | Set Headers | ${headers} | POST | endpoint=${endpoint} | body=${body}

asimell commented 2 years ago

Seems like the issue was caused by https://github.com/asyrjasalo/RESTinstance/commit/0b25bb81539fabfeb7ca8063dd337a1c39cfe233 when deepcopy was changed to copy. I'll fix this to Eficode fork and we'll merge it for the next release.

asimell commented 2 years ago

Seems like this is somewhat related to https://github.com/asyrjasalo/RESTinstance/issues/73. I fixed the copy to deepcopy, but getting the same error as I got for the fix in the comments of that issue. I'll try to see if there's a quick solution for this.

asimell commented 2 years ago

I created https://github.com/eficode/RESTinstance/pull/19 to fix this issue. Also new acceptance tests added to ensure this behaviour doesn't repeat in the future.

asimell commented 2 years ago

PR merged. This fix will be available in release 1.3.0, which we aim to do at beginning of February. Closing the issue for now.

leonpros commented 2 years ago

still having this issue. there is no way to unset a certain header?

scenario: create a REST request with header "token": "Bearer ..." and "Accept": "application/json" created by "Set Headers" keyword create a new request with header "Accept": "application/json" (without "token" header) created by "Set Headers" keyword

request is still sent with the "token" header

asimell commented 2 years ago

Currently no. There is ongoing discussion about this in #130 .