Skip to content

Commit 8b592dd

Browse files
authored
Merge pull request #31 from abhinvv1/master
Add ios keychain support param
2 parents 5c538f2 + 0ee5b3b commit 8b592dd

5 files changed

Lines changed: 47 additions & 4 deletions

File tree

lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ def self.run(params)
1616
browserstack_access_key = params[:browserstack_access_key] # Required
1717
custom_id = params[:custom_id]
1818
file_path = params[:file_path].to_s # Required
19+
ios_keychain_support = params[:ios_keychain_support]
1920

2021
validate_file_path(file_path)
22+
validate_ios_keychain_support(ios_keychain_support) unless ios_keychain_support.nil?
2123

2224
UI.message("Uploading app to BrowserStack AppAutomate...")
2325

24-
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT, custom_id)
26+
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT, custom_id, ios_keychain_support)
2527

2628
# Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful.
2729
ENV['BROWSERSTACK_APP_ID'] = browserstack_app_id
@@ -45,6 +47,19 @@ def self.validate_file_path(file_path)
4547
end
4648
end
4749

50+
# Validate ios_keychain_support
51+
def self.validate_ios_keychain_support(ios_keychain_support)
52+
platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
53+
if !platform.nil? && platform != :ios
54+
# Check if platform is specified and not ios
55+
# If so, then raise error.
56+
UI.user_error!("ios_keychain_support param can only be used with platform ios")
57+
end
58+
unless ['true', 'false'].include?(ios_keychain_support.to_s)
59+
UI.user_error!("ios_keychain_support should be either 'true' or 'false'.")
60+
end
61+
end
62+
4863
def self.description
4964
"Uploads IPA and APK files to BrowserStack AppAutomate for running automated tests."
5065
end
@@ -105,7 +120,11 @@ def self.available_options
105120
description: "Path to the app file",
106121
optional: true,
107122
is_string: true,
108-
default_value: default_file_path)
123+
default_value: default_file_path),
124+
FastlaneCore::ConfigItem.new(key: :ios_keychain_support,
125+
description: "Enable/disable support for iOS keychain",
126+
optional: true,
127+
is_string: true)
109128
]
110129
end
111130

lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.show_message
2020
# +custom_id+:: Custom id for app upload.
2121
# +file_path+:: Path to the file to be uploaded.
2222
# +url+:: BrowserStack's app upload endpoint.
23-
def self.upload_file(browserstack_username, browserstack_access_key, file_path, url, custom_id = nil)
23+
def self.upload_file(browserstack_username, browserstack_access_key, file_path, url, custom_id = nil, ios_keychain_support = nil)
2424
payload = {
2525
multipart: true,
2626
file: File.new(file_path, 'rb')
@@ -30,6 +30,10 @@ def self.upload_file(browserstack_username, browserstack_access_key, file_path,
3030
payload[:data] = '{ "custom_id": "' + custom_id + '" }'
3131
end
3232

33+
unless ios_keychain_support.nil?
34+
payload[:ios_keychain_support] = ios_keychain_support
35+
end
36+
3337
headers = {
3438
"User-Agent" => "browserstack_fastlane_plugin"
3539
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Fastlane
22
module Browserstack
3-
VERSION = "0.3.3"
3+
VERSION = "0.3.4"
44
end
55
end

spec/fixtures/HelloWorld.ipa

5.04 MB
Binary file not shown.

spec/upload_to_browserstack_app_automate_action_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,25 @@
146146
end").runner.execute(:test)
147147
expect(ENV['BROWSERSTACK_APP_ID']).to eq(custom_id)
148148
end
149+
150+
it "should work with ios keychain support" do
151+
ENV['BROWSERSTACK_APP_ID'] = nil
152+
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::IPA_OUTPUT_PATH] = nil
153+
expect(RestClient::Request).to receive(:execute).and_return({ "app_url" => "bs://app_url", "ios_keychain_support" => true }.to_json)
154+
fastfile = Fastlane::FastFile.new.parse("
155+
platform :ios do
156+
lane :test do
157+
upload_to_browserstack_app_automate({
158+
browserstack_username: 'username',
159+
browserstack_access_key: 'access_key',
160+
ios_keychain_support: 'true',
161+
file_path: File.join(FIXTURE_PATH, 'HelloWorld.ipa')
162+
})
163+
end
164+
end
165+
")
166+
fastfile.runner.execute(:test, :ios)
167+
expect(ENV['BROWSERSTACK_APP_ID']).to eq("bs://app_url")
168+
end
149169
end
150170
end

0 commit comments

Comments
 (0)