diff --git a/lib/httpx/plugins/basic_authentication.rb b/lib/httpx/plugins/basic_authentication.rb index 89db9ebc..a4378661 100644 --- a/lib/httpx/plugins/basic_authentication.rb +++ b/lib/httpx/plugins/basic_authentication.rb @@ -7,7 +7,7 @@ module HTTPX # # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#basic-authentication # - module BasicAuthentication + module BasicAuth class << self def load_dependencies(_klass) require_relative "authentication/basic" @@ -19,12 +19,12 @@ module HTTPX end module InstanceMethods - def basic_authentication(user, password) + def basic_auth(user, password) authentication(Authentication::Basic.new(user, password).authenticate) end - alias_method :basic_auth, :basic_authentication + alias_method :basic_authentication, :basic_auth end end - register_plugin :basic_authentication, BasicAuthentication + register_plugin :basic_authentication, BasicAuth end end diff --git a/lib/httpx/plugins/digest_authentication.rb b/lib/httpx/plugins/digest_authentication.rb index 15c6f0c5..704a154a 100644 --- a/lib/httpx/plugins/digest_authentication.rb +++ b/lib/httpx/plugins/digest_authentication.rb @@ -7,7 +7,7 @@ module HTTPX # # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#authentication # - module DigestAuthentication + module DigestAuth DigestError = Class.new(Error) class << self @@ -58,6 +58,6 @@ module HTTPX end end - register_plugin :digest_authentication, DigestAuthentication + register_plugin :digest_authentication, DigestAuth end end diff --git a/lib/httpx/plugins/ntlm_authentication.rb b/lib/httpx/plugins/ntlm_authentication.rb index 52ed1e3c..1e35d3e7 100644 --- a/lib/httpx/plugins/ntlm_authentication.rb +++ b/lib/httpx/plugins/ntlm_authentication.rb @@ -5,7 +5,7 @@ module HTTPX # # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#ntlm-authentication # - module NTLMAuthentication + module NTLMAuth class << self def load_dependencies(_klass) require_relative "authentication/ntlm" @@ -53,6 +53,6 @@ module HTTPX end end end - register_plugin :ntlm_authentication, NTLMAuthentication + register_plugin :ntlm_authentication, NTLMAuth end end diff --git a/sig/chainable.rbs b/sig/chainable.rbs index f32633a3..8202c55c 100644 --- a/sig/chainable.rbs +++ b/sig/chainable.rbs @@ -13,9 +13,9 @@ module HTTPX | (options) { (Session) -> void } -> void def plugin: (:authentication, ?options) -> Plugins::sessionAuthentication - | (:basic_authentication, ?options) -> Plugins::sessionBasicAuthentication - | (:digest_authentication, ?options) -> Plugins::sessionDigestAuthentication - | (:ntlm_authentication, ?options) -> Plugins::sessionNTLMAuthentication + | (:basic_authentication, ?options) -> Plugins::sessionBasicAuth + | (:digest_authentication, ?options) -> Plugins::sessionDigestAuth + | (:ntlm_authentication, ?options) -> Plugins::sessionNTLMAuth | (:aws_sdk_authentication, ?options) -> Plugins::sessionAwsSdkAuthentication | (:compression, ?options) -> Session | (:cookies, ?options) -> Plugins::sessionCookies diff --git a/sig/plugins/basic_authentication.rbs b/sig/plugins/basic_authentication.rbs index 6d7fd164..59c3b767 100644 --- a/sig/plugins/basic_authentication.rbs +++ b/sig/plugins/basic_authentication.rbs @@ -1,6 +1,6 @@ module HTTPX module Plugins - module BasicAuthentication + module BasicAuth def self.load_dependencies: (singleton(Session)) -> void def self.configure: (singleton(Session)) -> void @@ -10,6 +10,6 @@ module HTTPX end end - type sessionBasicAuthentication = sessionAuthentication & Authentication::InstanceMethods & BasicAuthentication::InstanceMethods + type sessionBasicAuth = sessionAuthentication & Authentication::InstanceMethods & BasicAuth::InstanceMethods end end diff --git a/sig/plugins/digest_authentication.rbs b/sig/plugins/digest_authentication.rbs index cf622c76..d38c7def 100644 --- a/sig/plugins/digest_authentication.rbs +++ b/sig/plugins/digest_authentication.rbs @@ -1,6 +1,6 @@ module HTTPX module Plugins - module DigestAuthentication + module DigestAuth DigestError: singleton(Error) interface _DigestOptions @@ -16,6 +16,6 @@ module HTTPX end end - type sessionDigestAuthentication = sessionAuthentication & DigestAuthentication::InstanceMethods + type sessionDigestAuth = sessionAuthentication & DigestAuth::InstanceMethods end end diff --git a/sig/plugins/ntlm_authentication.rbs b/sig/plugins/ntlm_authentication.rbs index 2b94781c..734d7f21 100644 --- a/sig/plugins/ntlm_authentication.rbs +++ b/sig/plugins/ntlm_authentication.rbs @@ -1,6 +1,6 @@ module HTTPX module Plugins - module NTLMAuthentication + module NTLMAuth interface _NTLMOptions def ntlm: () -> Authentication::Ntlm? @@ -16,6 +16,6 @@ module HTTPX end - type sessionNTLMAuthentication = sessionAuthentication & NTLMAuthentication::InstanceMethods + type sessionNTLMAuth = sessionAuthentication & NTLMAuth::InstanceMethods end end diff --git a/test/support/requests/plugins/authentication.rb b/test/support/requests/plugins/authentication.rb index 34cf5ea8..c99b4f03 100644 --- a/test/support/requests/plugins/authentication.rb +++ b/test/support/requests/plugins/authentication.rb @@ -12,13 +12,13 @@ module Requests no_auth_response.close session = HTTPX.plugin(:basic_authentication) - response = session.basic_authentication(user, pass).get(basic_auth_uri) + response = session.basic_auth(user, pass).get(basic_auth_uri) verify_status(response, 200) body = json_body(response) verify_header(body, "authenticated", true) verify_header(body, "user", user) - invalid_response = session.basic_authentication(user, "fake").get(basic_auth_uri) + invalid_response = session.basic_auth(user, "fake").get(basic_auth_uri) verify_status(invalid_response, 401) end @@ -26,7 +26,7 @@ module Requests def test_plugin_digest_authentication session = HTTPX.plugin(:digest_authentication).with_headers("cookie" => "fake=fake_value") - response = session.digest_authentication(user, pass).get(digest_auth_uri) + response = session.digest_auth(user, pass).get(digest_auth_uri) verify_status(response, 200) body = json_body(response) verify_header(body, "authenticated", true) @@ -36,7 +36,7 @@ module Requests %w[SHA1 SHA2 SHA256 SHA384 SHA512 RMD160].each do |alg| define_method "test_plugin_digest_authentication_#{alg}" do session = HTTPX.plugin(:digest_authentication).with_headers("cookie" => "fake=fake_value") - response = session.digest_authentication(user, pass).get("#{digest_auth_uri}/#{alg}") + response = session.digest_auth(user, pass).get("#{digest_auth_uri}/#{alg}") verify_status(response, 200) body = json_body(response) verify_header(body, "authenticated", true) @@ -57,7 +57,7 @@ module Requests verify_status(no_auth_response, 401) no_auth_response.close - response = http.ntlm_authentication("user", "password").get(uri) + response = http.ntlm_auth("user", "password").get(uri) verify_status(response, 200) # invalid_response = http.ntlm_authentication("user", "fake").get(uri) diff --git a/www/_data/plugins.yml b/www/_data/plugins.yml index 12fe8b99..e82dc8ba 100644 --- a/www/_data/plugins.yml +++ b/www/_data/plugins.yml @@ -1,5 +1,5 @@ - - name: BasicAuthentication + name: BasicAuth path: Authentication.html#basic-authentication description: API and support for Basic Authentication. -