lib/pact/provider/pact_uri.rb in pact-1.55.4 vs lib/pact/provider/pact_uri.rb in pact-1.55.5
- old
+ new
@@ -15,11 +15,11 @@
options == other.options &&
metadata == other.metadata
end
def basic_auth?
- !!username
+ !!username && !!password
end
def username
options[:username]
end
@@ -27,14 +27,25 @@
def password
options[:password]
end
def to_s
- if basic_auth? && uri.start_with?('http://', 'https://')
+ if basic_auth? && http_or_https_uri?
URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
+ elsif personal_access_token? && http_or_https_uri?
+ URI(@uri).tap { |x| x.userinfo="*****"}.to_s
else
uri
end
end
+
+ private def personal_access_token?
+ !!username && !password
+ end
+
+ private def http_or_https_uri?
+ uri.start_with?('http://', 'https://')
+ end
+
end
end
end