Skip to content

Instantly share code, notes, and snippets.

@tgk
Created August 14, 2012 05:57
Show Gist options
  • Save tgk/3346760 to your computer and use it in GitHub Desktop.
Save tgk/3346760 to your computer and use it in GitHub Desktop.
Test suite
(ns clj-http-test.core-test
(:use clojure.test
clj-http-test.core)
(:require [clj-http.client :as client]))
(deftest test-digest-auth
(testing "Testing that request with no auth fails"
(is (= 401
(:status (client/get "http://192.168.0.101/" {:throw-exceptions false})))))
(testing "Testing that basic auth fails as well"
(is (= 401
(:status (client/get "http://192.168.0.101/"
{:throw-exceptions false
:basic-auth ["tgk" "1234"]})))))
(testing "Testing that digest auth does work"
(is (= 200
(:status (client/get "http://192.168.0.101/"
{:throw-exceptions false
:digest-auth ["tgk" "1234"]}))))))
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.host_name = "apache"
config.vm.network :hostonly, "192.168.0.101"
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "apache2"
chef.add_recipe "apache2::mod_auth_digest"
chef.log_level = :debug
end
end
tgk:This is a secret area:92e2f9f03426871ee293d826a00f52b9
AuthType Digest
AuthName "This is a secret area"
AuthDigestProvider file
AuthUserFile /var/www/.digest_pw
Require valid-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment