1
- package provider
1
+ package provider_test
2
2
3
3
import (
4
4
"context"
9
9
"github.com/hashicorp/terraform-plugin-framework/diag"
10
10
"github.com/hashicorp/terraform-plugin-framework/types"
11
11
"github.com/pomerium/enterprise-client-go/pb"
12
+ "github.com/pomerium/enterprise-terraform-provider/internal/provider"
12
13
"github.com/stretchr/testify/assert"
13
14
"google.golang.org/protobuf/testing/protocmp"
14
15
)
@@ -22,15 +23,15 @@ func TestJWTGroupsFilterFromPB(t *testing.T) {
22
23
{
23
24
name : "nil input" ,
24
25
input : nil ,
25
- expected : types .ObjectNull (jwtGroupsFilterSchemaAttr ),
26
+ expected : types .ObjectNull (provider . JWTGroupsFilterSchemaAttr ),
26
27
},
27
28
{
28
29
name : "empty groups" ,
29
30
input : & pb.JwtGroupsFilter {
30
31
Groups : []string {},
31
- InferFromPpl : false ,
32
+ InferFromPpl : P ( false ) ,
32
33
},
33
- expected : types .ObjectValueMust (jwtGroupsFilterSchemaAttr , map [string ]attr.Value {
34
+ expected : types .ObjectValueMust (provider . JWTGroupsFilterSchemaAttr , map [string ]attr.Value {
34
35
"groups" : types .SetValueMust (types .StringType , []attr.Value {}),
35
36
"infer_from_ppl" : types .BoolValue (false ),
36
37
}),
@@ -39,9 +40,9 @@ func TestJWTGroupsFilterFromPB(t *testing.T) {
39
40
name : "with groups" ,
40
41
input : & pb.JwtGroupsFilter {
41
42
Groups : []string {"group1" , "group2" },
42
- InferFromPpl : true ,
43
+ InferFromPpl : P ( true ) ,
43
44
},
44
- expected : types .ObjectValueMust (jwtGroupsFilterSchemaAttr , map [string ]attr.Value {
45
+ expected : types .ObjectValueMust (provider . JWTGroupsFilterSchemaAttr , map [string ]attr.Value {
45
46
"groups" : types .SetValueMust (types .StringType , []attr.Value {
46
47
types .StringValue ("group1" ),
47
48
types .StringValue ("group2" ),
@@ -54,7 +55,7 @@ func TestJWTGroupsFilterFromPB(t *testing.T) {
54
55
for _ , tc := range tests {
55
56
t .Run (tc .name , func (t * testing.T ) {
56
57
var result types.Object
57
- JWTGroupsFilterFromPB (& result , tc .input )
58
+ provider . JWTGroupsFilterFromPB (& result , tc .input )
58
59
diff := cmp .Diff (tc .expected , result )
59
60
assert .Empty (t , diff )
60
61
})
@@ -70,23 +71,23 @@ func TestJWTGroupsFilterToPB(t *testing.T) {
70
71
}{
71
72
{
72
73
name : "null input" ,
73
- input : types .ObjectNull (jwtGroupsFilterSchemaAttr ),
74
+ input : types .ObjectNull (provider . JWTGroupsFilterSchemaAttr ),
74
75
expected : nil ,
75
76
},
76
77
{
77
78
name : "empty groups" ,
78
- input : types .ObjectValueMust (jwtGroupsFilterSchemaAttr , map [string ]attr.Value {
79
+ input : types .ObjectValueMust (provider . JWTGroupsFilterSchemaAttr , map [string ]attr.Value {
79
80
"groups" : types .SetValueMust (types .StringType , []attr.Value {}),
80
81
"infer_from_ppl" : types .BoolValue (false ),
81
82
}),
82
83
expected : & pb.JwtGroupsFilter {
83
84
Groups : []string {},
84
- InferFromPpl : false ,
85
+ InferFromPpl : P ( false ) ,
85
86
},
86
87
},
87
88
{
88
89
name : "with groups" ,
89
- input : types .ObjectValueMust (jwtGroupsFilterSchemaAttr , map [string ]attr.Value {
90
+ input : types .ObjectValueMust (provider . JWTGroupsFilterSchemaAttr , map [string ]attr.Value {
90
91
"groups" : types .SetValueMust (types .StringType , []attr.Value {
91
92
types .StringValue ("group1" ),
92
93
types .StringValue ("group2" ),
@@ -95,7 +96,7 @@ func TestJWTGroupsFilterToPB(t *testing.T) {
95
96
}),
96
97
expected : & pb.JwtGroupsFilter {
97
98
Groups : []string {"group1" , "group2" },
98
- InferFromPpl : true ,
99
+ InferFromPpl : P ( true ) ,
99
100
},
100
101
},
101
102
}
@@ -104,7 +105,7 @@ func TestJWTGroupsFilterToPB(t *testing.T) {
104
105
t .Run (tc .name , func (t * testing.T ) {
105
106
var diags diag.Diagnostics
106
107
var result * pb.JwtGroupsFilter
107
- JWTGroupsFilterToPB (ctx , & result , tc .input , & diags )
108
+ provider . JWTGroupsFilterToPB (ctx , & result , tc .input , & diags )
108
109
assert .False (t , diags .HasError ())
109
110
diff := cmp .Diff (tc .expected , result , protocmp .Transform ())
110
111
assert .Empty (t , diff )
0 commit comments