Skip to content

Commit

Permalink
Fix test by removing dns entry
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Nov 7, 2023
1 parent 3143fb5 commit 7f45ce2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
5 changes: 2 additions & 3 deletions internal/config/test_in_memory_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"Policies": {
"*": {
"Allow": [
"7.7.7.7",
"google.com"
"7.7.7.7"
]
},
"group:nerds": {
Expand Down Expand Up @@ -75,4 +74,4 @@
}
}
}
}
}
32 changes: 7 additions & 25 deletions internal/router/ebpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestAddUser(t *testing.T) {
for _, device := range out {
policiesTable, err := checkLPMMap(device.Username, xdpObjects.PoliciesTable)
if err != nil {
t.Fatal("checking publictable:", err)
t.Fatal("checking policy table:", err)
}

acl := config.GetEffectiveAcl(device.Username)
Expand All @@ -124,33 +124,15 @@ func TestAddUser(t *testing.T) {
t.Fatal("parsing rules failed?:", err)
}

var allow []string
resultsAsString := []string{}
for _, r := range results {

for _, k := range r.Keys {
allow = append(allow, k.String())
}
}

results, err = routetypes.ParseRules(acl.Mfa, acl.Allow, nil)
if err != nil {
t.Fatal("parsing rules failed?:", err)
}

var mfa []string
for _, r := range results {

for _, k := range r.Keys {
mfa = append(mfa, k.String())
for m := range r.Keys {
resultsAsString = append(resultsAsString, r.Keys[m].String())
}
}

if !contains(policiesTable, allow) {
t.Fatal("public allow list does not match configured acls\n got: ", policiesTable, "\nexpected:", allow)
}

if !contains(policiesTable, mfa) {
t.Fatal("mfa allow list does not match configured acls\n got: ", policiesTable, "\nexpected:", mfa)
if !contains(policiesTable, resultsAsString) {
t.Fatal("policies list does not match configured acls\n got: ", policiesTable, "\nexpected:", resultsAsString)
}

}
Expand Down Expand Up @@ -1365,7 +1347,7 @@ func checkLPMMap(username string, m *ebpf.Map) ([]string, error) {
result := []string{}

var innerKey []byte
var val uint8
var val [routetypes.MAX_POLICIES]routetypes.Policy
innerIter := innerMap.Iterate()
kv := routetypes.Key{}
for innerIter.Next(&innerKey, &val) {
Expand Down

0 comments on commit 7f45ce2

Please sign in to comment.