@@ -904,9 +904,11 @@ func TestSecurityApi_Read(t *testing.T) {
904904 "suspended_reason" : basetypes .NewStringNull (),
905905 },
906906 ),
907- Name : types .StringValue (readModel .Name ),
908- RegionId : types .StringValue (readModel .RegionId ),
909- Type : types .StringValue (string (readModel .Type )),
907+ Name : types .StringValue (readModel .Name ),
908+ RegionId : types .StringValue (readModel .RegionId ),
909+ Type : types .StringValue (string (readModel .Type )),
910+ AdminFeaturesPackage : basetypes .NewStringNull (),
911+ ProductTypes : types .ListNull (resource_security_project.ProductTypesValue {}.Type (ctx )),
910912 }
911913
912914 mockApiClient := mocks .NewMockClientWithResponsesInterface (ctrl )
@@ -977,9 +979,114 @@ func TestSecurityApi_Read(t *testing.T) {
977979 "suspended_reason" : basetypes .NewStringValue (* readModel .Metadata .SuspendedReason ),
978980 },
979981 ),
980- Name : types .StringValue (readModel .Name ),
981- RegionId : types .StringValue (readModel .RegionId ),
982- Type : types .StringValue (string (readModel .Type )),
982+ Name : types .StringValue (readModel .Name ),
983+ RegionId : types .StringValue (readModel .RegionId ),
984+ Type : types .StringValue (string (readModel .Type )),
985+ AdminFeaturesPackage : basetypes .NewStringNull (),
986+ ProductTypes : types .ListNull (resource_security_project.ProductTypesValue {}.Type (ctx )),
987+ }
988+
989+ mockApiClient := mocks .NewMockClientWithResponsesInterface (ctrl )
990+ mockApiClient .EXPECT ().
991+ GetSecurityProjectWithResponse (ctx , id ).
992+ Return (& serverless.GetSecurityProjectResponse {
993+ JSON200 : readModel ,
994+ }, nil )
995+
996+ return testData {
997+ client : mockApiClient ,
998+ id : id ,
999+ initialModel : initialModel ,
1000+ expectedModel : expectedModel ,
1001+ expectedFound : true ,
1002+ }
1003+ },
1004+ },
1005+ {
1006+ name : "should populate admin_features_package and product_types when provided in response" ,
1007+ testData : func (ctx context.Context ) testData {
1008+ id := "project id"
1009+ initialModel := resource_security_project.SecurityProjectModel {
1010+ Id : types .StringValue (id ),
1011+ }
1012+
1013+ adminFeaturesPackage := serverless .SecurityAdminFeaturesPackage ("enterprise" )
1014+ productTypes := []serverless.SecurityProductType {
1015+ {
1016+ ProductLine : "security" ,
1017+ ProductTier : "complete" ,
1018+ },
1019+ {
1020+ ProductLine : "cloud" ,
1021+ ProductTier : "complete" ,
1022+ },
1023+ }
1024+
1025+ readModel := & serverless.SecurityProject {
1026+ Id : id ,
1027+ Alias : "expected-alias-" + id [0 :6 ],
1028+ CloudId : "cloud-id" ,
1029+ Endpoints : serverless.SecurityProjectEndpoints {
1030+ Elasticsearch : "es-endpoint" ,
1031+ Kibana : "kib-endpoint" ,
1032+ Ingest : "ingest-endpoint" ,
1033+ },
1034+ Metadata : serverless.ProjectMetadata {
1035+ CreatedAt : time .Now (),
1036+ CreatedBy : "me" ,
1037+ OrganizationId : "1" ,
1038+ },
1039+ Name : "project-name" ,
1040+ RegionId : "nether" ,
1041+ Type : "security" ,
1042+ AdminFeaturesPackage : & adminFeaturesPackage ,
1043+ ProductTypes : & productTypes ,
1044+ }
1045+
1046+ expectedProductTypes := []attr.Value {
1047+ resource_security_project .NewProductTypesValueMust (
1048+ resource_security_project.ProductTypesValue {}.AttributeTypes (ctx ),
1049+ map [string ]attr.Value {
1050+ "product_line" : basetypes .NewStringValue ("security" ),
1051+ "product_tier" : basetypes .NewStringValue ("complete" ),
1052+ },
1053+ ),
1054+ resource_security_project .NewProductTypesValueMust (
1055+ resource_security_project.ProductTypesValue {}.AttributeTypes (ctx ),
1056+ map [string ]attr.Value {
1057+ "product_line" : basetypes .NewStringValue ("cloud" ),
1058+ "product_tier" : basetypes .NewStringValue ("complete" ),
1059+ },
1060+ ),
1061+ }
1062+
1063+ expectedModel := resource_security_project.SecurityProjectModel {
1064+ Id : types .StringValue (id ),
1065+ Alias : types .StringValue ("expected-alias" ),
1066+ CloudId : types .StringValue (readModel .CloudId ),
1067+ Endpoints : resource_security_project .NewEndpointsValueMust (
1068+ initialModel .Endpoints .AttributeTypes (ctx ),
1069+ map [string ]attr.Value {
1070+ "elasticsearch" : basetypes .NewStringValue (readModel .Endpoints .Elasticsearch ),
1071+ "kibana" : basetypes .NewStringValue (readModel .Endpoints .Kibana ),
1072+ "ingest" : basetypes .NewStringValue (readModel .Endpoints .Ingest ),
1073+ },
1074+ ),
1075+ Metadata : resource_security_project .NewMetadataValueMust (
1076+ initialModel .Metadata .AttributeTypes (ctx ),
1077+ map [string ]attr.Value {
1078+ "created_at" : basetypes .NewStringValue (readModel .Metadata .CreatedAt .String ()),
1079+ "created_by" : basetypes .NewStringValue (readModel .Metadata .CreatedBy ),
1080+ "organization_id" : basetypes .NewStringValue (readModel .Metadata .OrganizationId ),
1081+ "suspended_at" : basetypes .NewStringNull (),
1082+ "suspended_reason" : basetypes .NewStringNull (),
1083+ },
1084+ ),
1085+ Name : types .StringValue (readModel .Name ),
1086+ RegionId : types .StringValue (readModel .RegionId ),
1087+ Type : types .StringValue (string (readModel .Type )),
1088+ AdminFeaturesPackage : basetypes .NewStringValue ("enterprise" ),
1089+ ProductTypes : types .ListValueMust (resource_security_project.ProductTypesValue {}.Type (ctx ), expectedProductTypes ),
9831090 }
9841091
9851092 mockApiClient := mocks .NewMockClientWithResponsesInterface (ctrl )
0 commit comments