-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfigureTLFResource.rb
More file actions
212 lines (185 loc) · 6.5 KB
/
Copy pathConfigureTLFResource.rb
File metadata and controls
212 lines (185 loc) · 6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
require 'Plist'
require 'json'
class ConfigureTLFResource
KILL_SWITCH_VALID_URL = "http://sandp.devlab.ibm.com/mobile/KillSwitch1.htm"
KILL_SWITCH_INVALID_URL = "http://sandp.devlab.ibm.com/mobile/KillSwitch0.htm"
ADV_CONFIG_JSON = '../LibraryBuilds/Tealeaf/Debug/TLFResources.bundle/TealeafAdvancedConfig.json'
LAYOUT_CONFIG_JSON = '../LibraryBuilds/Tealeaf/Debug/TLFResources.bundle/TealeafLayoutConfig.json'
PLIST_LOCATION = "../LibraryBuilds/Tealeaf/Debug/TLFResources.bundle/TealeafBasicConfig.plist"
APP_PLIST_LOCATION = "./iOSAutomationTestApp/Info.plist"
EO_CORE_CONFIG = "../LibraryBuilds/EOCore/Debug/EOCoreSettings.bundle/EOCoreBasicConfig.plist"
def enableKillSwitch
result = Plist::parse_xml(PLIST_LOCATION)
puts "killSwitch status: #{result['KillSwitchEnabled']}"
result['KillSwitchEnabled'] = true
result['KillSwitchUrl'] = KILL_SWITCH_VALID_URL
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def disableKillSwitch
result = Plist::parse_xml(PLIST_LOCATION)
puts "killSwitch status: #{result['KillSwitchEnabled']}"
result['KillSwitchEnabled'] = false
result['KillSwitchUrl'] = KILL_SWITCH_INVALID_URL
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setKillSwitchURL(url)
result = Plist::parse_xml(PLIST_LOCATION)
puts "Current killSwitch url: #{result['KillSwitchUrl']}"
result['KillSwitchUrl'] = url
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setBundleIdentifier(name)
result = Plist::parse_xml(APP_PLIST_LOCATION)
puts "Result: #{result}"
puts "Current bundle id: #{result['CFBundleIdentifier']}"
result['CFBundleIdentifier'] = name
result.to_plist
Plist::Emit.save_plist(result, APP_PLIST_LOCATION)
end
def enableImageData
result = Plist::parse_xml(PLIST_LOCATION)
result['GetImageDataOnScreenLayout'] = true
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def disableImageData
result = Plist::parse_xml(PLIST_LOCATION)
result['GetImageDataOnScreenLayout'] = false
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setSessionizationCookieName(name)
result = Plist::parse_xml(PLIST_LOCATION)
result['SessionizationCookieName'] = name
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def enableGeolocation
result = Plist::parse_xml(PLIST_LOCATION)
result['LogLocationEnabled'] = true
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def disableGeolocation
result = Plist::parse_xml(PLIST_LOCATION)
result['LogLocationEnabled'] = false
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def enableGestureDetector
result = Plist::parse_xml(PLIST_LOCATION)
result['SetGestureDetector'] = true
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def disableGestureDetector
result = Plist::parse_xml(PLIST_LOCATION)
result['SetGestureDetector'] = false
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def disableNativeGestureCaptureOnWebView
result = Plist::parse_xml(PLIST_LOCATION)
result['CaptureNativeGesturesOnWebview'] = false
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def enableNativeGestureCaptureOnWebView
result = Plist::parse_xml(PLIST_LOCATION)
result['CaptureNativeGesturesOnWebview'] = true
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setSecureTextFieldMaskingLevel(logLevel)
result = Plist::parse_xml(PLIST_LOCATION)
result['Masking']['UITextFieldSecure'] = logLevel
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setStandardMaskingLevel
result = Plist::parse_xml(PLIST_LOCATION)
result['Masking']['HasMasking'] = true
result['Masking']['HasCustomMask'] = false
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setCustomMaskingLevel
result = Plist::parse_xml(PLIST_LOCATION)
result['Masking']['HasMasking'] = true
result['Masking']['HasCustomMask'] = true
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def enableIP
puts 'Inside enableIp'
file = File.read(ADV_CONFIG_JSON)
result = JSON.parse(file) #IO.read(ADV_CONFIG_JSON))
result['RemoveIp'] = false
res = JSON.pretty_generate(result)
File.write(ADV_CONFIG_JSON, res)
puts 'enable completed'
end
def maskIP
file = File.read(ADV_CONFIG_JSON)
result = JSON.parse(file) #IO.read(ADV_CONFIG_JSON))
result['RemoveIp'] = true
res = JSON.pretty_generate(result)
File.write(ADV_CONFIG_JSON, res)
end
def appendMapId(id, midValue)
file = File.read(LAYOUT_CONFIG_JSON)
result = JSON.parse(file)
result['AppendMapIds'][id] = {"mid" => midValue}
res = JSON.pretty_generate(result)
puts "Result JSON: #{res}"
File.write(LAYOUT_CONFIG_JSON, res)
end
def addAutoLayoutElement(className, valuesDict)
file = File.read(LAYOUT_CONFIG_JSON)
result = JSON.parse(file)
result['AutoLayout'][className] = valuesDict
res = JSON.pretty_generate(result)
puts "Result JSON: #{res}"
File.write(LAYOUT_CONFIG_JSON, res)
end
def setAppKey(key)
result = Plist::parse_xml(PLIST_LOCATION)
result['AppKey'] = key
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setPostMessageURL(url)
result = Plist::parse_xml(PLIST_LOCATION)
result['PostMessageUrl'] = url
result.to_plist
Plist::Emit.save_plist(result, PLIST_LOCATION)
end
def setManualPost
result = Plist::parse_xml(EO_CORE_CONFIG)
result['ManualPostEnabled'] = true
result.to_plist
Plist::Emit.save_plist(result, EO_CORE_CONFIG)
end
def disableManualPost
result = Plist::parse_xml(EO_CORE_CONFIG)
result['ManualPostEnabled'] = false
result.to_plist
Plist::Emit.save_plist(result, EO_CORE_CONFIG)
end
end
# create an object
#obj = ConfigureTLFResource.new
#puts 'Enabling KillSwitch'
#obj.enableKillSwitch()
#puts 'Disable KillSwitch'
#obj.disableKillSwitch()
#puts 'Setting secure textField masking level to 3'
#obj.setSecureTextFieldMaskingLevel(3)
#obj.enableGestureDetector()
#puts 'Enabling IP'
#obj.enableIP
#obj.appendMapId("[w,1],[v,1],[v,1],[v,0],[v,0],[t,0]", "customField_Peggy")
#obj.addAutoLayoutElement("HomeViewController", {"do" => true, "screenViewName" => "Banana", "delay" => 120, "takeScreenShot" => false})