@@ -29,7 +29,7 @@ func TestListGroupVariabless(t *testing.T) {
2929 mux .HandleFunc ("/api/v4/groups/1/variables" ,
3030 func (w http.ResponseWriter , r * http.Request ) {
3131 testMethod (t , r , http .MethodGet )
32- fmt .Fprint (w , `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}]` )
32+ fmt .Fprint (w , `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": true }]` )
3333 })
3434
3535 variables , _ , err := client .GroupVariables .ListVariables (1 , & ListGroupVariablesOptions {})
@@ -43,6 +43,7 @@ func TestListGroupVariabless(t *testing.T) {
4343 Value : "test1" ,
4444 Protected : false ,
4545 Masked : true ,
46+ Hidden : true ,
4647 },
4748 }
4849
@@ -58,15 +59,15 @@ func TestGetGroupVariable(t *testing.T) {
5859 func (w http.ResponseWriter , r * http.Request ) {
5960 testMethod (t , r , http .MethodGet )
6061 testParams (t , r , "filter%5Benvironment_scope%5D=prod" )
61- fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}` )
62+ fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": false }` )
6263 })
6364
6465 variable , _ , err := client .GroupVariables .GetVariable (1 , "TEST_VARIABLE_1" , & GetGroupVariableOptions {Filter : & VariableFilter {EnvironmentScope : "prod" }})
6566 if err != nil {
6667 t .Errorf ("GroupVariables.GetVariable returned error: %v" , err )
6768 }
6869
69- want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true }
70+ want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true , Hidden : false }
7071 if ! reflect .DeepEqual (want , variable ) {
7172 t .Errorf ("GroupVariables.GetVariable returned %+v, want %+v" , variable , want )
7273 }
@@ -78,22 +79,51 @@ func TestCreateGroupVariable(t *testing.T) {
7879 mux .HandleFunc ("/api/v4/groups/1/variables" ,
7980 func (w http.ResponseWriter , r * http.Request ) {
8081 testMethod (t , r , http .MethodPost )
81- fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}` )
82+ fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value":"test1","protected": false,"masked": true,"hidden": false }` )
8283 })
8384
8485 opt := & CreateGroupVariableOptions {
85- Key : Ptr ("TEST_VARIABLE_1" ),
86- Value : Ptr ("test1" ),
87- Protected : Ptr (false ),
88- Masked : Ptr (true ),
86+ Key : Ptr ("TEST_VARIABLE_1" ),
87+ Value : Ptr ("test1" ),
88+ Protected : Ptr (false ),
89+ Masked : Ptr (true ),
90+ MaskedAndHidden : Ptr (false ),
8991 }
9092
9193 variable , _ , err := client .GroupVariables .CreateVariable (1 , opt , nil )
9294 if err != nil {
9395 t .Errorf ("GroupVariables.CreateVariable returned error: %v" , err )
9496 }
9597
96- want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true }
98+ want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true , Hidden : false }
99+ if ! reflect .DeepEqual (want , variable ) {
100+ t .Errorf ("GroupVariables.CreateVariable returned %+v, want %+v" , variable , want )
101+ }
102+ }
103+
104+ func TestCreateGroupVariable_MaskedAndHidden (t * testing.T ) {
105+ mux , client := setup (t )
106+
107+ mux .HandleFunc ("/api/v4/groups/1/variables" ,
108+ func (w http.ResponseWriter , r * http.Request ) {
109+ testMethod (t , r , http .MethodPost )
110+ fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","protected": false,"masked": true,"hidden": true}` )
111+ })
112+
113+ opt := & CreateGroupVariableOptions {
114+ Key : Ptr ("TEST_VARIABLE_1" ),
115+ Value : Ptr ("test1" ),
116+ Protected : Ptr (false ),
117+ Masked : Ptr (true ),
118+ MaskedAndHidden : Ptr (true ),
119+ }
120+
121+ variable , _ , err := client .GroupVariables .CreateVariable (1 , opt , nil )
122+ if err != nil {
123+ t .Errorf ("GroupVariables.CreateVariable returned error: %v" , err )
124+ }
125+
126+ want := & GroupVariable {Key : "TEST_VARIABLE_1" , Protected : false , Masked : true , Hidden : true }
97127 if ! reflect .DeepEqual (want , variable ) {
98128 t .Errorf ("GroupVariables.CreateVariable returned %+v, want %+v" , variable , want )
99129 }
@@ -126,15 +156,35 @@ func TestUpdateGroupVariable(t *testing.T) {
126156 mux .HandleFunc ("/api/v4/groups/1/variables/TEST_VARIABLE_1" ,
127157 func (w http.ResponseWriter , r * http.Request ) {
128158 testMethod (t , r , http .MethodPut )
129- fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}` )
159+ fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": false}` )
160+ })
161+
162+ variable , _ , err := client .GroupVariables .UpdateVariable (1 , "TEST_VARIABLE_1" , & UpdateGroupVariableOptions {})
163+ if err != nil {
164+ t .Errorf ("GroupVariables.UpdateVariable returned error: %v" , err )
165+ }
166+
167+ want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true , Hidden : false }
168+ if ! reflect .DeepEqual (want , variable ) {
169+ t .Errorf ("Groups.UpdatedGroup returned %+v, want %+v" , variable , want )
170+ }
171+ }
172+
173+ func TestUpdateGroupVariable_MaskedAndHidden (t * testing.T ) {
174+ mux , client := setup (t )
175+
176+ mux .HandleFunc ("/api/v4/groups/1/variables/TEST_VARIABLE_1" ,
177+ func (w http.ResponseWriter , r * http.Request ) {
178+ testMethod (t , r , http .MethodPut )
179+ fmt .Fprint (w , `{"key": "TEST_VARIABLE_1","protected": false,"masked": true,"hidden": true}` )
130180 })
131181
132182 variable , _ , err := client .GroupVariables .UpdateVariable (1 , "TEST_VARIABLE_1" , & UpdateGroupVariableOptions {})
133183 if err != nil {
134184 t .Errorf ("GroupVariables.UpdateVariable returned error: %v" , err )
135185 }
136186
137- want := & GroupVariable {Key : "TEST_VARIABLE_1" , Value : "test1" , Protected : false , Masked : true }
187+ want := & GroupVariable {Key : "TEST_VARIABLE_1" , Protected : false , Masked : true , Hidden : true }
138188 if ! reflect .DeepEqual (want , variable ) {
139189 t .Errorf ("Groups.UpdatedGroup returned %+v, want %+v" , variable , want )
140190 }
0 commit comments