mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
#9260 - [X] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - ~[ ] Documented any API changes (docs/Using-Fleet/REST-API.md or docs/Contributing/API-for-contributors.md)~ - ~[ ] Documented any permissions changes~ - ~[ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements)~ - ~[ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for new osquery data ingestion features.~ - [X] Added/updated tests - [X] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [X] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - ~[ ] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).~
39 lines
1 KiB
Go
39 lines
1 KiB
Go
//go:build darwin
|
|
// +build darwin
|
|
|
|
package authdb
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestParseAuthDBReadOutput(t *testing.T) {
|
|
const systemLoginScreensaver = `<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>class</key>
|
|
<string>rule</string>
|
|
<key>created</key>
|
|
<real>656503622.12447298</real>
|
|
<key>modified</key>
|
|
<real>697495406.285501</real>
|
|
<key>rule</key>
|
|
<array>
|
|
<string>authenticate-session-owner-or-admin</string>
|
|
</array>
|
|
<key>version</key>
|
|
<integer>0</integer>
|
|
</dict>
|
|
</plist>`
|
|
m, err := parseAuthDBReadOutput([]byte(systemLoginScreensaver))
|
|
require.NoError(t, err)
|
|
require.NotNil(t, m["rule"])
|
|
rule, ok := m["rule"].([]interface{})
|
|
require.True(t, ok)
|
|
require.Len(t, rule, 1)
|
|
require.Equal(t, "authenticate-session-owner-or-admin", rule[0])
|
|
require.Equal(t, "rule", m["class"])
|
|
}
|