Skip to content

Commit 034bdf6

Browse files
committed
cleaned up grant_test.go
1 parent ad48ea1 commit 034bdf6

1 file changed

Lines changed: 2 additions & 52 deletions

File tree

grant_test.go

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,13 @@ import (
66
)
77

88
func Test_parseAcls(t *testing.T) {
9-
doParseAcls(t, "c42ro=rwa/c42", "c42ro", 3)
9+
doParseAcls(t, "user1=rwa/c42", "user1", 3)
1010
doParseAcls(t, "=arwdDxt/c42", "public", 7) // first of two lines
11-
doParseAcls(t, "c42=rwad/postgres", "c42", 4) // second of two lines
11+
doParseAcls(t, "u3=rwad/postgres", "u3", 4) // second of two lines
1212
doParseAcls(t, "user2=arwxt/postgres", "user2", 5)
1313
doParseAcls(t, "", "", 0)
1414
}
1515

16-
/*
17-
schema | type | relationship_name | relationship_acl | column_name | column_acl
18-
--------+----------+-----------------------------------------------+----------------------+------------------------------+-------------
19-
public | TABLE | t_brand | c42ro=r/c42 | |
20-
public | TABLE | t_brand | office42=arwdDxt/c42 | |
21-
public | TABLE | t_brand | c42=arwdDxt/c42 | |
22-
public | TABLE | t_computer | c42=arwdDxt/c42 | active | c42ro=r/c42
23-
public | TABLE | t_computer | office42=arwdDxt/c42 | active | c42ro=r/c42
24-
public | TABLE | t_computer | c42=arwdDxt/c42 | address | c42ro=r/c42
25-
public | TABLE | t_computer | office42=arwdDxt/c42 | address | c42ro=r/c42
26-
*/
27-
28-
// Note that these must be sorted for this to work
29-
var relationship1 = []map[string]string{
30-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "relationship_acl": "c42=rwa/postgres"},
31-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "relationship_acl": "o42=xdwra/postgres"},
32-
{"schema": "public", "type": "TABLE", "relationship_name": "table2", "relationship_acl": "c42=rwa/postgres"},
33-
}
34-
35-
// Note that these must be sorted for this to work
36-
var relationship2 = []map[string]string{
37-
{"schema": "public", "relationship_name": "table1", "type": "TABLE", "relationship_acl": "c42=r/postgres"},
38-
{"schema": "public", "relationship_name": "table2", "type": "TABLE", "relationship_acl": "c42=rwad/postgres"},
39-
}
40-
41-
// Note that these must be sorted for this to work
42-
var attribute1 = []map[string]string{
43-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "attribute_name": "column1", "attribute_acl": "c42ro=r/postgres"},
44-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "attribute_name": "column1", "attribute_acl": "o42ro=rwa/postgres"},
45-
{"schema": "public", "type": "TABLE", "relationship_name": "table2", "attribute_name": "column2", "attribute_acl": "c42ro=r/postgres"},
46-
}
47-
48-
// Note that these must be sorted for this to work
49-
var attribute2 = []map[string]string{
50-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "attribute_name": "column1", "attribute_acl": "c42ro=r/postgres"},
51-
{"schema": "public", "type": "TABLE", "relationship_name": "table1", "attribute_name": "column1", "attribute_acl": "o42ro=r/postgres"},
52-
}
53-
54-
func Test_diffGrants(t *testing.T) {
55-
fmt.Println("-- ==========\n-- Grants - Relationships \n-- ==========")
56-
var relSchema1 Schema = &GrantRelationshipSchema{rows: relationship1, rowNum: -1}
57-
var relSchema2 Schema = &GrantRelationshipSchema{rows: relationship2, rowNum: -1}
58-
doDiff(relSchema1, relSchema2)
59-
60-
fmt.Println("-- ==========\n-- Grants - Attributes \n-- ==========")
61-
var attSchema1 Schema = &GrantAttributeSchema{rows: attribute1, rowNum: -1}
62-
var attSchema2 Schema = &GrantAttributeSchema{rows: attribute2, rowNum: -1}
63-
doDiff(attSchema1, attSchema2)
64-
}
65-
6616
func doParseAcls(t *testing.T, acl string, expectedRole string, expectedPermCount int) {
6717
fmt.Println("Testing", acl)
6818
role, perms := parseAcl(acl)

0 commit comments

Comments
 (0)