lib/kashi/dsl/test.rb in kashi-0.1.0.beta1 vs lib/kashi/dsl/test.rb in kashi-0.1.0
- old
+ new
@@ -1,26 +1,30 @@
require 'ostruct'
+require 'kashi/secret_expander'
module Kashi
class DSL
class Test
class Result
PARAMS = %i/
TestID Paused WebsiteName WebsiteURL Port NodeLocations Timeout CustomHeader Confirmation CheckRate
DNSServer DNSIP BasicUser BasicPass LogoImage UseJar WebsiteHost Virus FindString DoNotFind
TestType ContactGroup TriggerRate TestTags StatusCodes EnableSSLWarning FollowRedirect
+ PostRaw FinalEndpoint
/ # PingURL RealBrowser Public Branding
ATTRIBUTES = %i/
test_id paused website_name website_url port node_locations timeout custom_header confirmation check_rate
dns_server dns_ip basic_user basic_pass logo_image use_jar website_host virus find_string do_not_find
test_type contact_group trigger_rate test_tags status_codes enable_ssl_warning follow_redirect
+ post_raw final_endpoint
/ # ping_url real_browser public branding
attr_accessor *ATTRIBUTES
def initialize(context)
@context = context
@options = context.options
+ @options[:secret_expander] = SecretExpander.new(@options[:secret_provider]) if @options[:secret_provider]
end
def to_h
Hash[ATTRIBUTES.sort.map { |name| [name, public_send(name)] }]
end
@@ -99,17 +103,27 @@
end
def modify
return unless updated?
Kashi.logger.info("Modify Test `#{website_name}` #{test_id}")
- Kashi.logger.info("<diff>\n#{Kashi::Utils.diff(sc_hash, dsl_hash, color: @options[:color])}")
+ masked_dsl_has = dsl_hash.dup.tap { |h| h[:basic_pass] = '****' }
+ Kashi.logger.info("<diff>\n#{Kashi::Utils.diff(sc_hash, masked_dsl_has, color: @options[:color])}")
Kashi.logger.debug(modify_params)
return if @options[:dry_run]
client.tests_update(modify_params)
end
+ def basic_pass
+ secret_expander = @options[:secret_expander]
+ if secret_expander
+ secret_expander.expand(@basic_pass)
+ else
+ @basic_pass
+ end
+ end
+
def client
@client ||= ClientWrapper.new(@options)
end
end
@@ -136,9 +150,13 @@
@result.follow_redirect = 1
@result.test_tags = []
@result.node_locations = ['']
@result.status_codes = []
@result.virus = ''
+
+ # not used
+ @result.post_raw = ''
+ @result.final_endpoint = ''
instance_eval(&block)
end
private