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 support for all proxy schemes, not just https:// #2289

Merged
merged 16 commits into from
Aug 22, 2022

Conversation

canth1
Copy link
Contributor

@canth1 canth1 commented Aug 10, 2022

This commit fixes #2285 by supporting all mod_proxy schemes according to the documentation here:

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

@canth1 canth1 requested a review from a team as a code owner August 10, 2022 20:39
@ekohl
Copy link
Collaborator

ekohl commented Aug 12, 2022

Looks like the tests fail on this.

I also wonder if this should be a type alias.

@david22swan
Copy link
Member

Looks like the tests fail on this.

I also wonder if this should be a type alias.

I would agree on this

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

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

@canth1
Hey, look's like you've got a few failing tests

Also, think that @ekohl suggestion is a good one and that this would be a good use of a type alias to keep the code neater

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Small detail, but this looks good.

@@ -0,0 +1,3 @@
# @summary Supported protocols / schemes by mod_proxy
# @see https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
type Apache::ModProxyProtocol = Pattern[/(\A(ajp|fcgi|ftp|h2|h2c|http|https|scgi|uwsgi|ws|wss):\/\/.*\z)/, /(\Aunix:\/([^\n\/\0]+\/*)*\z)/]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it valid to not specify anything or should it be

Suggested change
type Apache::ModProxyProtocol = Pattern[/(\A(ajp|fcgi|ftp|h2|h2c|http|https|scgi|uwsgi|ws|wss):\/\/.*\z)/, /(\Aunix:\/([^\n\/\0]+\/*)*\z)/]
type Apache::ModProxyProtocol = Pattern[/(\A(ajp|fcgi|ftp|h2|h2c|http|https|scgi|uwsgi|ws|wss):\/\/.+\z)/, /(\Aunix:\/([^\n\/\0]+\/*)*\z)/]

@ekohl ekohl changed the title -Add support for all proxy schemes, not just https:// Add support for all proxy schemes, not just https:// Aug 17, 2022
Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Looks like the tests are failing.

Also, it's possible to add tests for a type alias: https://rspec-puppet.com/documentation/type_aliases/

@canth1
Copy link
Contributor Author

canth1 commented Aug 17, 2022

Is it valid to not specify anything or should it be

I don't think that's correct, because I took my regex directly from Stdlib:HTTPSUrl

https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/types/httpsurl.pp

Which is:

type Stdlib::HTTPSUrl = Pattern[/(?i:\Ahttps://.*\z)/]

@canth1
Copy link
Contributor Author

canth1 commented Aug 17, 2022

Looks like the tests are failing.

Also, it's possible to add tests for a type alias: https://rspec-puppet.com/documentation/type_aliases/

Ok, I'll add the tests for this new type alias.

@ekohl
Copy link
Collaborator

ekohl commented Aug 17, 2022

Small detail, but this looks good.

I don't think that's correct, because I took my regex directly from Stdlib:HTTPSUrl

https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/types/httpsurl.pp

Which is:

type Stdlib::HTTPSUrl = Pattern[/(?i:\Ahttps://.*\z)/]

Interesting. That implies it also accepts https:// which doesn't make sense to me since I don't consider it an HTTP(S) URL.

@@ -0,0 +1,3 @@
# @summary Supported protocols / schemes by mod_proxy
# @see https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
type Apache::ModProxyProtocol = Pattern[/(\A(ajp|fcgi|ftp|h2c?|https?|scgi|uwsgi|wss?):\/\/.*\z)/, /(\Aunix:\/([^\n\/\0]+\/*)*\z)/]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is correct. The filename must match the type name.

@canth1
Copy link
Contributor Author

canth1 commented Aug 17, 2022

Small detail, but this looks good.

I don't think that's correct, because I took my regex directly from Stdlib:HTTPSUrl
https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/types/httpsurl.pp
Which is:
type Stdlib::HTTPSUrl = Pattern[/(?i:\Ahttps://.*\z)/]

Interesting. That implies it also accepts https:// which doesn't make sense to me since I don't consider it an HTTP(S) URL.

Actually, you're correct. We shouldn't allow an empty value after ://

I'll fix that with your suggestion.

It looks like the Stdlib:HTTPSUrl allows that for some reason?

@ekohl
Copy link
Collaborator

ekohl commented Aug 17, 2022

It looks like the Stdlib:HTTPSUrl allows that for some reason?

Possibly an oversight and nobody ran into problems because of it.

@canth1
Copy link
Contributor Author

canth1 commented Aug 17, 2022

The spec tests are failing, but I can't figure out why?

Resource type not found: Apache::ModProxyProtocol

Not sure why it's giving me that error?

@ekohl
Copy link
Collaborator

ekohl commented Aug 17, 2022

Because of #2289 (comment). You must name it according to the conventions so the loader finds it, so types/mod_proxy_protocol.pp.

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

This looks good to me. @david22swan you requested changes, mind taking another look? Also, IMHO we should squash this on merge.

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

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

LGTM

Everything look's good to me, only small comment is that the variables aren't aligned, but since there are only two of them it's not that big of a deal in my eyes.
Will go ahead with a squash merge.

@david22swan david22swan merged commit 92c47e1 into puppetlabs:main Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apache:Balancermember configured data type no longer allows previously valid settings
4 participants