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

added redirect match support #499

Closed
wants to merge 12 commits into from
Closed

added redirect match support #499

wants to merge 12 commits into from

Conversation

pablokbs
Copy link

Please check it now

@pablokbs
Copy link
Author

@igalic Sorry for the delay

'404',
],
:redirectmatch_regexp => [
'/\\.git(/.*|$)',
Copy link
Contributor

Choose a reason for hiding this comment

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

That's one \ too many. From the looks of the travis build error.

Copy link
Author

Choose a reason for hiding this comment

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

That's weird, I have that configuration working on an apache virtualhost:

Redirect rules

RedirectMatch 404 /.git(/.*|$)

http://www.foreclosuredatabank.com/.git

@apenney
Copy link
Contributor

apenney commented Nov 26, 2013

Unfortunately the tests are breaking on this. Can I ask you to take a look at travis? It looks like it'll be an easy one to fix, just have to tweak the test then "rake spec" to test it.

@pablokbs
Copy link
Author

Removed the extra slash and it works on apache also :squirrel:

@pablokbs
Copy link
Author

Do I have to do something to refresh the test? Travis is using the same code I think

@igalic
Copy link
Contributor

igalic commented Nov 26, 2013

I'd squash and force-push those two commits,

% git rebase -i HEAD~2
...
% git push -f origin redirect_match_support

@pablokbs
Copy link
Author

Done

@igalic
Copy link
Contributor

igalic commented Nov 26, 2013

@kclair
Copy link

kclair commented Nov 29, 2013

I'm a little confused by the implementation of this. So the intention is that the full redirect text (regex AND destination) are added to $redirectmatch_regexp ? For example, if I wanted to redirect ^/(.*.gif)$ to /images/gifs/$1, would I do this?

$redirectmatch_regexp => '^/(.*.gif)$ http://otherserver.com/images/gifs/$1`

I'm curious about why the different implementation than the redirect params, which break out source and dest. Seems like the redirect params should be consistent between Redirect and RedirectMatch.

@pablokbs
Copy link
Author

Yes, exactly, is the same as redirect but you can use regular expresions.

@apenney @igalic I'm running rake spec on my computer now, I will test it here before uploading, thanks

@pablokbs
Copy link
Author

pablokbs commented Dec 1, 2013

I will need some help here, I can't make that test work, it's always failing no matter how I escape the characters, I'm using grep and it works. How does this test make the matching expression checking? Is there I way I can test it by hand? Every rake spec test takes about 10 minutes on my computer

@pablokbs
Copy link
Author

pablokbs commented Dec 5, 2013

Any help?

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

I'm looking at this now.

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

first off, this is how to run the spec tests:

igalic@levix ~/src/puppet/puppetlabs-apache (git)-[redirect_match] % rspec --format d --color --backtrace spec/defines/vhost_spec.rb -e 'redirect match rules'
Run options: include {:full_description=>/redirect\ match\ rules/}

apache::vhost
  os-independent items
    attribute resources
      redirect rules
        redirect match rules
          example at ./spec/defines/vhost_spec.rb:1015 (FAILED - 1)

Failures:

  1) apache::vhost os-independent items attribute resources redirect rules redirect match rules
     Failure/Error: it { should contain_file("25-#{title}.conf").with_content %r{  RedirectMatch 404 /\\\.git(/\.*|$)} }
     Puppet::Error:
       Could not parse for environment production: No file(s) found for import of '/home/igalic/src/puppet/puppetlabs-apache/spec/fixtures/manifests/site.pp' at line 3 on node levix
     # /usr/lib/ruby/vendor_ruby/puppet/parser/parser_support.rb:166:in `rescue in parse'
     # /usr/lib/ruby/vendor_ruby/puppet/parser/parser_support.rb:157:in `parse'

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

next, test rules here http://rubular.com/

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

diff --git spec/defines/vhost_spec.rb spec/defines/vhost_spec.rb
index 1bd1aff..2e3a03e 100644
--- spec/defines/vhost_spec.rb
+++ spec/defines/vhost_spec.rb
@@ -1002,6 +1002,7 @@ describe 'apache::vhost', :type => :define do
         end
         describe 'redirect match rules' do
           let :params do
+            ## XXX As mentioned above, rspec-puppet drops constructs like $1 and makes it hard to correctly escape \.
             default_params.merge({
               :redirectmatch_status => [
                 '404',
@@ -1012,7 +1013,7 @@ describe 'apache::vhost', :type => :define do
             })
           end

-          it { should contain_file("25-#{title}.conf").with_content %r{  RedirectMatch 404 /\\\.git(/\.*|$)} }
+          it { should contain_file("25-#{title}.conf").with_content %r{  RedirectMatch 404 } }
         end
         describe 'without a status' do
           let :params do

and the test:

igalic@levix ~/src/puppet/puppetlabs-apache (git)-[redirect_match] % rake spec_clean spec_prep
Cloning into 'spec/fixtures/modules/stdlib'...
remote: Counting objects: 4350, done.
remote: Compressing objects: 100% (2538/2538), done.
remote: Total 4350 (delta 1657), reused 3916 (delta 1272)
Receiving objects: 100% (4350/4350), 768.28 KiB | 272.00 KiB/s, done.
Resolving deltas: 100% (1657/1657), done.
Checking connectivity... done
Cloning into 'spec/fixtures/modules/concat'...
remote: Counting objects: 762, done.
remote: Compressing objects: 100% (538/538), done.
remote: Total 762 (delta 312), reused 617 (delta 197)
Receiving objects: 100% (762/762), 138.42 KiB | 213.00 KiB/s, done.
Resolving deltas: 100% (312/312), done.
Checking connectivity... done
igalic@levix ~/src/puppet/puppetlabs-apache (git)-[redirect_match] % rspec --format d --color --backtrace spec/defines/vhost_spec.rb -e 'redirect match rules'
Run options: include {:full_description=>/redirect\ match\ rules/}

apache::vhost
  os-independent items
    attribute resources
      redirect rules
        redirect match rules
          should contain File[25-rspec.example.com.conf] with content matching /  RedirectMatch 404 /

Finished in 5.63 seconds
1 example, 0 failures
rspec --format d --color --backtrace spec/defines/vhost_spec.rb -e   8,42s user 0,23s system 100% cpu 8,646 total
igalic@levix ~/src/puppet/puppetlabs-apache (git)-[redirect_match] %   

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

But, in general, and I'm sorry I'm saying this only now: I have to agree with @kclair:

The parameters should be a list of hashes that break everything up, analogous to redirects, and analogous to all other directives.

@igalic
Copy link
Contributor

igalic commented Dec 5, 2013

Perhaps it would be even better to do this analogous to the multiple rewrites (#373) patch.

@kclair
Copy link

kclair commented Dec 6, 2013

i'm not sure that i agree that it is analogous to rewrites because the directives (Rewrite and RewriteMatch) are actually different. To consolidate them would necessitate either a flag to indicate it's a RewriteMatch rather than a Rewrite, or trying to auto-detect a regex (ugh!).

@pablokbs
Copy link
Author

pablokbs commented Dec 8, 2013

Hello again

Sorry I didn't really understand your response. I see you've removed the regular expresion and the test went fine. I did the same at my computer and it works also. Do you want me to do that?

@igalic
Copy link
Contributor

igalic commented Dec 10, 2013

Yes. For now, please do that. This is a bug in rspec-puppet

antaflos and others added 8 commits December 10, 2013 09:44
When managing directories (or locations, files) through the
`directories` parameter the resulting vhost configuration file contains
a few empty lines too many. This cleans up these unnecessary empty
lines, leaving just one between Directory blocks. This is a purely
cosmetic change.
(#479) Extend the _aliases.erb template so that the list of hashes in
`apache::vhost`'s `aliases` parameter can contain the usual `alias`
hashes but also `aliasmatch` hashes, which get translated to
`AliasMatch` directives.

Includes basic spec tests and updated documentation in README.md. Note
that these spec tests are currently only skeletons because rspec-puppet
drops constructs like '$1'. See the entries marked XXX.
Don't implicitly add a trailing slash to the path components of
ScriptAlias directives. Includes updated spec tests. Fixes issue #489.
Remove the `authnz_ldap` key from $mod_packages in `apache::params` so
an installation of the non-existent package `libapache2-mod-authz-ldap`
is not attempted.

Properly manage the `authnz_ldap.conf` file template and set the
`LDAPVerifyServerCert` directive according to $verifyServerCert
in `apache::mod::authnz_ldap`.

Also update spec tests accordingly.

This fixes only the superficial problems in issue #494. Better support
for mod_ldap and mod_authnz_ldap is required, as discussed there.
add support for overriding ErrorDocument settings in both, vhost and
directory context.
With documentation and tests included this fixes #474
Pablo Fredrikson added 3 commits December 10, 2013 09:44
@blkperl
Copy link
Contributor

blkperl commented Dec 13, 2013

Looks like a few other commits snuck in, can you rebase this against master.

@blkperl
Copy link
Contributor

blkperl commented Dec 13, 2013

Looks like you submitted a second PR for this in #521. I'll close this one then

@blkperl blkperl closed this Dec 13, 2013
traylenator pushed a commit to traylenator/puppetlabs-apache that referenced this pull request Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants