test/test_http.rb in atom-tools-0.9.2 vs test/test_http.rb in atom-tools-0.9.3

- old
+ new

@@ -148,28 +148,35 @@ end # no credentials assert_raises(Atom::Unauthorized) { get_root } + # incorrect credentials @http.user = USER @http.pass = "incorrect_password" one_shot - # incorrect credentials assert_raises(Atom::Unauthorized) { get_root } + # no credentials, fancy block + @http.when_auth do nil end + + one_shot + + assert_raises(Atom::Unauthorized) { get_root } + + # correct credentials, fancy block @http.when_auth do |abs_url,realm| assert_equal "http://localhost:#{@port}/", abs_url assert_equal REALM, realm [USER, PASS] end - + one_shot - - # correct credentials + assert_authenticates end def test_digest_auth # a dummy userdb (saves me creating a file) @@ -216,14 +223,11 @@ p = @http.send :parse_quoted_wwwauth, xwsse assert_equal USER, p[:Username] assert_match /^UsernameToken /, xwsse - # un-base64 in preparation for SHA1-ing - nonce = p[:Nonce].unpack("m").first - # Base64( SHA1( Nonce + CreationTimestamp + Password ) ) - pd_string = nonce + p[:Created] + PASS + pd_string = p[:Nonce] + p[:Created] + PASS password_digest = [Digest::SHA1.digest(pd_string)].pack("m").chomp assert_equal password_digest, p[:PasswordDigest] res.body = SECRET_DATA