Skip to content
Merged
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: testdata
testdata:
go run . \
-f testdata/input-parent.hujson \
-d testdata/departments/ \
-o testdata/output-file-to-compare-to.hujson \
-allow=acls,grants,groups,ipsets,ssh,tests
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
"extraDNSRecords": handleArray(),
"grants": handleArray(),
"groups": handleObject(),
"ipsets": handleObject(),
"nodeAttrs": handleArray(), // TODO: need to merge anything?
"postures": handleObject(),
"ssh": handleArray(),
Expand Down
5 changes: 5 additions & 0 deletions testdata/departments/finance/ipsets.hujson
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ipsets": {
"ipset:finance": ["192.0.2.1"],
},
}
4 changes: 4 additions & 0 deletions testdata/input-parent.hujson
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@
"tag:dave": [],
"tag:jane": [],
},

"ipsets": {
"ipset:parent": ["192.0.2.0"],
},
}
35 changes: 25 additions & 10 deletions testdata/output-file-to-compare-to.hujson
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
// from `testdata/input-parent.hujson`
"RandomizeClientPort": true, // inline comment

"acls": [
// from testdata/departments/engineering/acls.hujson
// from `testdata/input-parent.hujson`
{
// engineering1
"action": "accept",
Expand All @@ -27,14 +28,14 @@
"dst": ["tag:demo-infra:22"],
"srcPosture": ["posture:latestMac"],
},
// from testdata/departments/engineering/acls.json
// from `testdata/departments/engineering/acls.json`
{
"action": "accept",
"src": ["[email protected]"],
"dst": ["tag:json-rule:22"],
"srcPosture": ["posture:latestMac"],
},
// from testdata/departments/finance/acls.hujson
// from `testdata/departments/finance/acls.hujson`
{
// finance1
"action": "accept",
Expand All @@ -51,6 +52,7 @@
},
],

// from `testdata/input-parent.hujson`
"extraDNSRecords": [
{
"Name": "exra.dns.records",
Expand All @@ -59,7 +61,7 @@
],

"grants": [
// from testdata/departments/engineering/grants.hujson
// from `testdata/departments/engineering/grants.hujson`
{
//"src": ["group:prod"],
"src": ["[email protected]"],
Expand All @@ -70,15 +72,25 @@
],

"groups": {
// from `testdata/input-parent.hujson`
"group:parent": ["from-parent"],

// from testdata/departments/engineering/groups.hujson
// from `testdata/departments/engineering/groups.hujson`
"group:group1": ["[email protected]"],

// from testdata/departments/finance/acls.hujson
// from `testdata/departments/finance/acls.hujson`
"group:group2": ["[email protected]"],
},

"ipsets": {
// from `testdata/input-parent.hujson`
"ipset:parent": ["192.0.2.0"],

// from `testdata/departments/finance/ipsets.hujson`
"ipset:parent": ["192.0.2.1"],
},

// from `testdata/input-parent.hujson`
"nodeAttrs": [
{
"target": ["*"],
Expand All @@ -105,23 +117,25 @@
},
],

// from `testdata/input-parent.hujson`
"postures": {"posture:latestMac": ["node:os IN ['macos', 'linux']","node:tsReleaseTrack == 'stable'","node:tsVersion >= '1.40'"]},

"ssh": [
// from `testdata/input-parent.hujson`
{
"action": "accept",
"src": ["autogroup:member"],
"dst": ["autogroup:self"],
"users": ["root", "autogroup:nonroot"],
},
// from testdata/departments/engineering/acls.hujson
// from `testdata/departments/engineering/acls.hujson`
{
"action": "accept",
"src": ["group:finance"],
"dst": ["autogroup:self"],
"users": ["root", "autogroup:nonroot"],
},
// from testdata/departments/finance/ssh.hujson
// from `testdata/departments/finance/ssh.hujson`
{
"action": "accept",
"src": ["autogroup:member"],
Expand All @@ -136,6 +150,7 @@
},
],

// from `testdata/input-parent.hujson`
"tagOwners": {
"tag:parent": [],
"tag:cameron": ["autogroup:member"],
Expand All @@ -144,12 +159,12 @@
},

"tests": [
// from testdata/departments/engineering/acls.hujson
// from `testdata/input-parent.hujson`
{
"src": "[email protected]",
"accept": ["tag:cameron:22"],
},
// from testdata/departments/finance/acls.hujson
// from `testdata/departments/finance/acls.hujson`
{
"src": "[email protected]",
"srcPostureAttrs": {"node:os": "windows"},
Expand Down