...
1
16
17 package datapol
18
19 import (
20 "crypto/x509"
21 "net/http"
22 "testing"
23
24 "github.com/stretchr/testify/assert"
25 )
26
27 func TestTypes(t *testing.T) {
28 testcases := []struct {
29 value interface{}
30 expect []string
31 }{{
32 value: http.Header{},
33 expect: []string{"password", "token"},
34 }, {
35 value: http.Cookie{},
36 expect: []string{"token"},
37 }, {
38 value: x509.Certificate{},
39 expect: []string{"security-key"},
40 }}
41 for _, tc := range testcases {
42 types := GlobalDatapolicyMapping(tc.value)
43 if !assert.ElementsMatch(t, tc.expect, types) {
44 t.Errorf("Wrong set of datatypes detected for %T, want: %v, got %v", tc.value, tc.expect, types)
45 }
46 }
47 }
48
View as plain text