Skip to content

fix: Comprehensive field compatibility fixes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions internal/ksm/complex_fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,3 +1064,183 @@ func TestIsSensitiveFieldComprehensive(t *testing.T) {
})
}
}

func TestProcessAppFillerField(t *testing.T) {
client := &Client{}

tests := []struct {
name string
value interface{}
unmask bool
expected interface{}
found bool
}{
{
name: "app filler - masked",
value: []interface{}{
map[string]interface{}{
"applicationTitle": "Banking App",
"contentFilter": "input[type=password]",
"macroSequence": "username{TAB}password{ENTER}",
},
},
unmask: false,
expected: []map[string]interface{}{
{
"applicationTitle": "Banking App",
"contentFilter": "input[type=password]",
"macroSequence": "use***ER}",
},
},
found: true,
},
{
name: "app filler - unmasked",
value: []interface{}{
map[string]interface{}{
"applicationTitle": "Shopping Site",
"contentFilter": ".login-form",
"macroSequence": "[email protected]{TAB}SecurePass123{ENTER}",
},
},
unmask: true,
expected: []map[string]interface{}{
{
"applicationTitle": "Shopping Site",
"contentFilter": ".login-form",
"macroSequence": "[email protected]{TAB}SecurePass123{ENTER}",
},
},
found: true,
},
{
name: "minimal app filler",
value: []interface{}{
map[string]interface{}{
"applicationTitle": "Simple App",
},
},
unmask: false,
expected: []map[string]interface{}{
{
"applicationTitle": "Simple App",
},
},
found: true,
},
{
name: "empty value",
value: []interface{}{},
unmask: false,
expected: nil,
found: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, found := client.processAppFillerField(tt.value, tt.unmask)
assert.Equal(t, tt.found, found, "Found status should match")
if tt.found {
assert.Equal(t, tt.expected, result, "App filler data should match")
}
})
}
}

func TestProcessScheduleField(t *testing.T) {
client := &Client{}

tests := []struct {
name string
value interface{}
unmask bool
expected interface{}
found bool
}{
{
name: "complete schedule",
value: []interface{}{
map[string]interface{}{
"type": "Monthly",
"time": "14:30",
"cron": "0 14 1 * *",
"tz": "America/New_York",
"weekday": "1",
"intervalCount": float64(1),
},
},
unmask: false,
expected: []map[string]interface{}{
{
"type": "Monthly",
"time": "14:30",
"cron": "0 14 1 * *",
"tz": "America/New_York",
"weekday": "1",
"intervalCount": float64(1),
},
},
found: true,
},
{
name: "weekly schedule",
value: []interface{}{
map[string]interface{}{
"type": "Weekly",
"time": "09:00",
},
},
unmask: false,
expected: []map[string]interface{}{
{
"type": "Weekly",
"time": "09:00",
},
},
found: true,
},
{
name: "multiple schedules",
value: []interface{}{
map[string]interface{}{
"type": "Daily",
"time": "06:00",
},
map[string]interface{}{
"type": "Weekly",
"time": "12:00",
},
},
unmask: false,
expected: []map[string]interface{}{
{
"type": "Daily",
"time": "06:00",
},
{
"type": "Weekly",
"time": "12:00",
},
},
found: true,
},
{
name: "empty value",
value: []interface{}{},
unmask: false,
expected: nil,
found: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, found := client.processScheduleField(tt.value, tt.unmask)
assert.Equal(t, tt.found, found, "Found status should match")
if tt.found {
assert.Equal(t, tt.expected, result, "Schedule data should match")
}
})
}
}
Loading
Loading