Skip to content

Instantly share code, notes, and snippets.

@rmg
Created May 6, 2014 20:54
Show Gist options
  • Save rmg/9c6fff4ebb4cc7b6ede7 to your computer and use it in GitHub Desktop.
Save rmg/9c6fff4ebb4cc7b6ede7 to your computer and use it in GitHub Desktop.
Testing basic auth proxy
#!/usr/local/bin/node
process.stdin.on('data', function data(input) {
console.error(input);
switch(input.toString()) {
case 'user allow\n':
case 'user pass\n':
process.stdout.write('OK\n');
break;
case 'user error\n':
process.stdout.write('BH\n');
break;
default:
process.stdout.write('ERR\n');
}
});
auth_param basic program /path/to/basic_auth.js
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
http_access deny all
http_port 3128
cache deny all
  1. Use squid.conf with squid 3.2+
  2. export HTTP_PROXY=http://user:allow@localhost:3128/
  3. run your $HTTP_PROXY aware test for success case
  4. export HTTP_PROXY=http://user:fail@localhost:3128/
  5. run your $HTTP_PROXY aware test for auth failure case
  6. export HTTP_PROXY=http://user:error@localhost:3128/
  7. run your $HTTP_PROXY aware test for auth error case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment