From 2c703703ac60fa8fc78a56c5a26dc5262deeb167 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:13:37 -0700 Subject: [PATCH] fix(v24): widen IdentityProviderDataType enum to include value 4 GET /IdentityProviders on an OAuth-enabled Command instance can return a Parameters[].DataType of 4 (observed against an Authentik-backed identity provider), but this generated enum only allowed [1,2,3], causing the entire []IdentityProviderIdentityProviderGetResponse slice to fail JSON decoding with "4 is not a valid CSSCMSDataModelEnumsIdentityProviderDataType". The v25 module's canonical swagger-generated enum already includes 4; this hand-edit brings v24 in line with it, matching the project's existing hand-edit precedent for enums with incomplete generated ranges (e.g. EnrollmentType [0..3] -> [0..7]). --- ...model_enums_identity_provider_data_type.go | 2 + ..._enums_identity_provider_data_type_test.go | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type_test.go diff --git a/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type.go b/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type.go index 6275aca..4023bcc 100644 --- a/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type.go +++ b/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type.go @@ -34,6 +34,7 @@ const ( CSSCMSDATAMODELENUMSIDENTITYPROVIDERDATATYPE__1 CSSCMSDataModelEnumsIdentityProviderDataType = 1 CSSCMSDATAMODELENUMSIDENTITYPROVIDERDATATYPE__2 CSSCMSDataModelEnumsIdentityProviderDataType = 2 CSSCMSDATAMODELENUMSIDENTITYPROVIDERDATATYPE__3 CSSCMSDataModelEnumsIdentityProviderDataType = 3 + CSSCMSDATAMODELENUMSIDENTITYPROVIDERDATATYPE__4 CSSCMSDataModelEnumsIdentityProviderDataType = 4 ) func ParseCSSCMSDataModelEnumsIdentityProviderDataType(s string) (*CSSCMSDataModelEnumsIdentityProviderDataType, error) { @@ -62,6 +63,7 @@ var AllowedCSSCMSDataModelEnumsIdentityProviderDataTypeEnumValues = []CSSCMSData 1, 2, 3, + 4, } func (v *CSSCMSDataModelEnumsIdentityProviderDataType) UnmarshalJSON(src []byte) error { diff --git a/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type_test.go b/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type_test.go new file mode 100644 index 0000000..945f5ff --- /dev/null +++ b/v24/api/keyfactor/v1/model_css_cms_data_model_enums_identity_provider_data_type_test.go @@ -0,0 +1,53 @@ +/* +Copyright 2026 Keyfactor +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain a +copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless +required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES +OR CONDITIONS OF ANY KIND, either express or implied. See the License for +the specific language governing permissions and limitations under the +License. +*/ + +package v1 + +import ( + "encoding/json" + "strconv" + "testing" +) + +// TestCSSCMSDataModelEnumsIdentityProviderDataType_UnmarshalJSON_KnownValues +// verifies that all wire values Command is known to emit for this enum +// deserialize without error. Value 4 regresses a bug where GET +// /IdentityProviders on an OAuth-enabled Command instance (observed against +// an Authentik-backed identity provider) returned a Parameters[].DataType of +// 4, but this generated enum only allowed [1,2,3], causing the entire +// []IdentityProviderIdentityProviderGetResponse response to fail to decode +// with "4 is not a valid CSSCMSDataModelEnumsIdentityProviderDataType". The +// v25 module's canonical swagger-generated enum already includes 4; this +// hand-edit brings v24 in line with it. +func TestCSSCMSDataModelEnumsIdentityProviderDataType_UnmarshalJSON_KnownValues(t *testing.T) { + for _, want := range AllowedCSSCMSDataModelEnumsIdentityProviderDataTypeEnumValues { + var got CSSCMSDataModelEnumsIdentityProviderDataType + payload := []byte(strconv.Itoa(int(want))) + if err := json.Unmarshal(payload, &got); err != nil { + t.Errorf("unexpected error unmarshaling value %d: %v", want, err) + } + if got != want { + t.Errorf("expected %v, got %v", want, got) + } + } +} + +// TestCSSCMSDataModelEnumsIdentityProviderDataType_UnmarshalJSON_OutOfRange +// verifies that a value outside the known set still produces a clear error +// instead of silently accepting it. +func TestCSSCMSDataModelEnumsIdentityProviderDataType_UnmarshalJSON_OutOfRange(t *testing.T) { + var got CSSCMSDataModelEnumsIdentityProviderDataType + err := json.Unmarshal([]byte("42"), &got) + if err == nil { + t.Fatalf("expected error for out-of-range value, got nil (value=%v)", got) + } +}