diff --git a/group_variables.go b/group_variables.go index 69fe44592..7978e594e 100644 --- a/group_variables.go +++ b/group_variables.go @@ -41,6 +41,7 @@ type GroupVariable struct { VariableType VariableTypeValue `json:"variable_type"` Protected bool `json:"protected"` Masked bool `json:"masked"` + Hidden bool `json:"hidden"` Raw bool `json:"raw"` EnvironmentScope string `json:"environment_scope"` Description string `json:"description"` @@ -127,6 +128,7 @@ type CreateGroupVariableOptions struct { Description *string `url:"description,omitempty" json:"description,omitempty"` EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` Masked *bool `url:"masked,omitempty" json:"masked,omitempty"` + MaskedAndHidden *bool `url:"masked_and_hidden,omitempty" json:"hidden,omitempty"` Protected *bool `url:"protected,omitempty" json:"protected,omitempty"` Raw *bool `url:"raw,omitempty" json:"raw,omitempty"` VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"` diff --git a/group_variables_test.go b/group_variables_test.go index 4d79d3927..0c0de84bb 100644 --- a/group_variables_test.go +++ b/group_variables_test.go @@ -29,7 +29,7 @@ func TestListGroupVariabless(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) - fmt.Fprint(w, `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}]`) + fmt.Fprint(w, `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": true}]`) }) variables, _, err := client.GroupVariables.ListVariables(1, &ListGroupVariablesOptions{}) @@ -43,6 +43,7 @@ func TestListGroupVariabless(t *testing.T) { Value: "test1", Protected: false, Masked: true, + Hidden: true, }, } @@ -58,7 +59,7 @@ func TestGetGroupVariable(t *testing.T) { func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) testParams(t, r, "filter%5Benvironment_scope%5D=prod") - fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) + fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": false}`) }) variable, _, err := client.GroupVariables.GetVariable(1, "TEST_VARIABLE_1", &GetGroupVariableOptions{Filter: &VariableFilter{EnvironmentScope: "prod"}}) @@ -66,7 +67,7 @@ func TestGetGroupVariable(t *testing.T) { t.Errorf("GroupVariables.GetVariable returned error: %v", err) } - want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true} + want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: false} if !reflect.DeepEqual(want, variable) { t.Errorf("GroupVariables.GetVariable returned %+v, want %+v", variable, want) } @@ -78,14 +79,15 @@ func TestCreateGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) + fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value":"test1","protected": false,"masked": true,"hidden": false}`) }) opt := &CreateGroupVariableOptions{ - Key: Ptr("TEST_VARIABLE_1"), - Value: Ptr("test1"), - Protected: Ptr(false), - Masked: Ptr(true), + Key: Ptr("TEST_VARIABLE_1"), + Value: Ptr("test1"), + Protected: Ptr(false), + Masked: Ptr(true), + MaskedAndHidden: Ptr(false), } variable, _, err := client.GroupVariables.CreateVariable(1, opt, nil) @@ -93,7 +95,35 @@ func TestCreateGroupVariable(t *testing.T) { t.Errorf("GroupVariables.CreateVariable returned error: %v", err) } - want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true} + want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: false} + if !reflect.DeepEqual(want, variable) { + t.Errorf("GroupVariables.CreateVariable returned %+v, want %+v", variable, want) + } +} + +func TestCreateGroupVariable_MaskedAndHidden(t *testing.T) { + mux, client := setup(t) + + mux.HandleFunc("/api/v4/groups/1/variables", + func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodPost) + fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","protected": false,"masked": true,"hidden": true}`) + }) + + opt := &CreateGroupVariableOptions{ + Key: Ptr("TEST_VARIABLE_1"), + Value: Ptr("test1"), + Protected: Ptr(false), + Masked: Ptr(true), + MaskedAndHidden: Ptr(true), + } + + variable, _, err := client.GroupVariables.CreateVariable(1, opt, nil) + if err != nil { + t.Errorf("GroupVariables.CreateVariable returned error: %v", err) + } + + want := &GroupVariable{Key: "TEST_VARIABLE_1", Protected: false, Masked: true, Hidden: true} if !reflect.DeepEqual(want, variable) { t.Errorf("GroupVariables.CreateVariable returned %+v, want %+v", variable, want) } @@ -126,7 +156,27 @@ func TestUpdateGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) - fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) + fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": false}`) + }) + + variable, _, err := client.GroupVariables.UpdateVariable(1, "TEST_VARIABLE_1", &UpdateGroupVariableOptions{}) + if err != nil { + t.Errorf("GroupVariables.UpdateVariable returned error: %v", err) + } + + want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: false} + if !reflect.DeepEqual(want, variable) { + t.Errorf("Groups.UpdatedGroup returned %+v, want %+v", variable, want) + } +} + +func TestUpdateGroupVariable_MaskedAndHidden(t *testing.T) { + mux, client := setup(t) + + mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1", + func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodPut) + fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","protected": false,"masked": true,"hidden": true}`) }) variable, _, err := client.GroupVariables.UpdateVariable(1, "TEST_VARIABLE_1", &UpdateGroupVariableOptions{}) @@ -134,7 +184,7 @@ func TestUpdateGroupVariable(t *testing.T) { t.Errorf("GroupVariables.UpdateVariable returned error: %v", err) } - want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true} + want := &GroupVariable{Key: "TEST_VARIABLE_1", Protected: false, Masked: true, Hidden: true} if !reflect.DeepEqual(want, variable) { t.Errorf("Groups.UpdatedGroup returned %+v, want %+v", variable, want) }