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

Implement "Unset Headers" keyword #134

Open mrehanabbasi opened 2 years ago

mrehanabbasi commented 2 years ago

Add the keyword "Unset Headers" to unset existing headers.

asimell commented 2 years ago

Thanks for the PR @mrehanabbasi ! Could you please open this PR to the Eficode fork of this repo? We'll collect a release there and then make a release PR here.

It might be only me, but I think unset headers in a bit out of line with most of Robot Framework's other keywords and I think it would be better if the name was remove headers. However, this is possibly only my preference, so it's not that big of a deal.

Also, it's unclear from the keyword documentation whether something like Unset Header Authorization will work. I think it would be good if the header is removable with or without the value. See #130 for details.

For debugging purposes, it could be also useful if the keyword (optionally) logged headers that were not deleted or even throws an error depending on the use case, e.g

My Test Case
    Unset Headers    non-existant
-->
[Warn]    Unable to remove header 'non-existant'
mrehanabbasi commented 2 years ago

Hey @asimell.

It might be only me, but I think unset headers in a bit out of line with most of Robot Framework's other keywords and I think it would be better if the name was remove headers. However, this is possibly only my preference, so it's not that big of a deal.

It is okay either way for me. I can make the changes if you want.

Also, it's unclear from the keyword documentation whether something like Unset Header Authorization will work. I think it would be good if the header is removable with or without the value. See #130 for details.

It won't work with the existing code. I do plan on updating it soon as it is more developer-friendly.

For debugging purposes, it could be also useful if the keyword (optionally) logged headers that were not deleted or even throws an error depending on the use case, e.g

My Test Case
    Unset Headers    non-existant
-->
[Warn]    Unable to remove header 'non-existant'

That is a nice suggestion. I'll add this as well.

Could you please open this PR to the Eficode fork of this repo? We'll collect a release there and then make a release PR here.

I will do that after making the necessary changes suggested above.

asimell commented 2 years ago

It won't work with the existing code. I do plan on updating it soon as it is more developer-friendly.

Could you elaborate on this a bit? What do you mean by "more developer-friendly"?

Could you also add acceptance tests for this new keyword (atest/headers.robot) to verify that it actually works?

mrehanabbasi commented 2 years ago

Could you elaborate on this a bit? What do you mean by "more developer-friendly"?

I meant that adding only header names instead of the whole values will be more "developer-friendly".

Could you also add acceptance tests for this new keyword (atest/headers.robot) to verify that it actually works?

Will try.

asimell commented 2 years ago

Ah, sorry, I misread your initial comment. I read it as "the current code is not developer-friendly, so I will not do it". 😅 Please, carry on.