Skip to content

Commit 03df6a1

Browse files
authored
Merge pull request #234 from Alpaca00/feature/clientsecret-from-firstmatch
Add support for extracting clientSecret from W3C firstMatch capabilities
2 parents 065475b + 7220a1b commit 03df6a1

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

common/models/appium.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,24 @@ type AppiumSession struct {
127127

128128
// ExtractClientSecretFromSession extracts client secret from Appium session request
129129
func ExtractClientSecretFromSession(sessionReq map[string]interface{}, prefix string) string {
130-
// Check capabilities.alwaysMatch (W3C format)
130+
// Check capabilities (W3C format)
131131
if caps, ok := sessionReq["capabilities"].(map[string]interface{}); ok {
132+
// Check capabilities.alwaysMatch (W3C format)
132133
if alwaysMatch, ok := caps["alwaysMatch"].(map[string]interface{}); ok {
133134
if secret, ok := alwaysMatch[prefix+":clientSecret"].(string); ok {
134135
return secret
135136
}
136137
}
138+
// Check capabilities.firstMatch (W3C format)
139+
if firstMatch, ok := caps["firstMatch"].([]interface{}); ok {
140+
for _, item := range firstMatch {
141+
if firstCaps, ok := item.(map[string]interface{}); ok {
142+
if secret, ok := firstCaps[prefix+":clientSecret"].(string); ok {
143+
return secret
144+
}
145+
}
146+
}
147+
}
137148
}
138149

139150
// Also check desiredCapabilities for backward compatibility

0 commit comments

Comments
 (0)