Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cacert to .fields in HttpProxy #923

Merged
merged 2 commits into from
May 22, 2023
Merged

Conversation

damoore044
Copy link
Contributor

@damoore044 damoore044 commented May 11, 2023

Description of changes

Add cacert to .fields in http_proxy, which is the path within the host to the cacert for the proxy.
Supports robottelo PR# 11454

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (64ca919) 91.83% compared to head (eea3d64) 91.83%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #923   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files           6        6           
  Lines        3000     3001    +1     
=======================================
+ Hits         2755     2756    +1     
  Misses        245      245           
Impacted Files Coverage Δ
nailgun/entities.py 90.77% <100.00%> (+<0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@damoore044 damoore044 changed the title Add cacert to .fields in HttpProxy [WIP] Add cacert to .fields in HttpProxy May 18, 2023
@damoore044 damoore044 marked this pull request as ready for review May 18, 2023 16:34
@damoore044 damoore044 added the CherryPick PR needs CherryPick to previous branches label May 18, 2023
@damoore044 damoore044 requested review from a team and vsedmik May 18, 2023 16:52
Copy link
Contributor

@vsedmik vsedmik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO you also need to add the field into the ignore list, as this field is not returned back on GET request and thus should be ignored when missing in the response:

[root@satellite ~]# curl -sku admin:changeme -H "Content-type: application/json" -X GET https://$(hostname)/api/http_proxies/1 | json_reformat
{
    "id": 1,
    "name": "AwesomeProxy",
    "url": "http://my.awesome.proxy.com:3128",
    "username": null,
    "locations": [
        {
            "id": 2,
            "name": "Default Location",
            "title": "Default Location"
        }
    ],
    "organizations": [ ]
}

just few lines lower:

if ignore is None:
    ignore = set()
ignore.add('cacert')
ignore.add('password')
...

@Griffin-Sullivan
Copy link
Contributor

Yeah I think @damoore044 was about to try curl to see what is returned from the GET. For reference David, nailgun entities are designed to look for any of the attributes defined in __init__() when receiving a GET request (in this case the read function). So for this instance, we defined the cacert field in the __init__, and now when we try to run something like proxy.read() it will go through each field listed in the init and see what value was returned for that field. However, the GET request to the proxy endpoint doesn't include cacert, so when nailgun doesn't find it we get a KeyError. This situation is pretty common, especially with things like password since we don't want it to be readable. So when this happens, we have a set named ignore which we can add our key to so that nailgun knows to not look for it when we run the read.

Here's the code that implements the logic I just explained: https://github.com/SatelliteQE/nailgun/blob/master/nailgun/entity_mixins.py#L777

All you need to do is add ignore.add('cacert'), to the HTTPProxy's read method.

@jyejare
Copy link
Member

jyejare commented May 19, 2023

Very nice explanation @Griffin-Sullivan !!

@damoore044 Please do it before we merge !

Copy link
Member

@jyejare jyejare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK pending @vsedmik comment for ignoring the field in read.

@damoore044
Copy link
Contributor Author

Thanks @Griffin-Sullivan for the helpful explanation, just addressed those

@jyejare jyejare merged commit 9d5b535 into SatelliteQE:master May 22, 2023
github-actions bot pushed a commit that referenced this pull request May 22, 2023
* Add cacert to .fields in HttpProxy

* ignore cacert in http-proxy.read()

(cherry picked from commit 9d5b535)
damoore044 added a commit that referenced this pull request Jun 1, 2023
* Add cacert to .fields in HttpProxy

* ignore cacert in http-proxy.read()

(cherry picked from commit 9d5b535)
jyejare pushed a commit that referenced this pull request Jun 2, 2023
* Add cacert to .fields in HttpProxy

* ignore cacert in http-proxy.read()

(cherry picked from commit 9d5b535)

Co-authored-by: David Moore <109112035+damoore044@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.13.z CherryPick PR needs CherryPick to previous branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants