Skip to content

Commit

Permalink
check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chkp-omerma committed Nov 12, 2024
1 parent 97739ab commit 32666aa
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 183 deletions.
20 changes: 10 additions & 10 deletions internal/models/web-api-practice/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ type FileSchema struct {
Data string `json:"data"`
}

type OASSchema struct {
Data string `json:"data"`
Name string `json:"name"`
Size uint64 `json:"size"`
}

type SchemaValidationSchema struct {
ID string `json:"id"`
OASSchema OASSchema `json:"OasSchema"`
}
//type OASSchema struct {
// Data string `json:"data"`
// Name string `json:"name"`
// Size uint64 `json:"size"`
//}
//
//type SchemaValidationSchema struct {
// ID string `json:"id"`
// OASSchema OASSchema `json:"OasSchema"`
//}

func NewFileSchemaEncode(filename, fileData string) FileSchema {
b64Data := base64.StdEncoding.EncodeToString([]byte(fileData))
Expand Down
21 changes: 0 additions & 21 deletions internal/resources/tests/web-api-asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,6 @@ resource "inext_web_api_practice" %[4]q {
illegal_http_methods = true
}
}
schema_validation {
oas_schema {
data = "data"
name = "name"
size = 100
}
}
}
resource "inext_log_trigger" %[5]q {
Expand Down Expand Up @@ -510,13 +503,6 @@ resource "inext_web_api_practice" %[4]q {
illegal_http_methods = true
}
}
schema_validation {
oas_schema {
data = "data"
name = "name"
size = 100
}
}
}
resource "inext_log_trigger" %[5]q {
Expand Down Expand Up @@ -711,13 +697,6 @@ resource "inext_web_api_practice" %[4]q {
illegal_http_methods = true
}
}
schema_validation {
oas_schema {
data = "data"
name = "name"
size = 100
}
}
}
resource "inext_log_trigger" %[5]q {
Expand Down
82 changes: 38 additions & 44 deletions internal/resources/tests/web-api-practice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ func TestAccWebAPIPracticeBasic(t *testing.T) {
"ips.0.low_confidence": "Detect",
"ips.0.performance_impact": "MediumOrLower",
"ips.0.%": "7",
//"schema_validation.0.filename": "",
"schema_validation.0.filename": "",
//"schema_validation.0.oas_schema.name": "",
//"schema_validation.0.oas_schema.size": "",
//"schema_validation.0.oas_schema.data": "",
//"schema_validation.0.oas_schema.%": "",
"api_attacks.#": "1",
"ips.0.severity_level": "MediumOrAbove",
//"schema_validation.0.data": "",
"practice_type": "WebAPI",
"default": "false",
"ips.0.medium_confidence": "Prevent",
"schema_validation.0.%": "2",
"category": "ThreatPrevention",
"api_attacks.0.%": "3",
"ips.0.high_confidence": "Prevent",
//"api_attacks.0.advanced_setting.0.body_size": "1000000",
//"api_attacks.0.advanced_setting.0.url_size": "32768",
//"api_attacks.0.advanced_setting.0.header_size": "102400",
//"api_attacks.0.advanced_setting.0.%": "6",
//"api_attacks.0.advanced_setting.0.max_object_depth": "40",
//"api_attacks.0.advanced_setting.0.illegal_http_methods": "false",
"api_attacks.#": "1",
"ips.0.severity_level": "MediumOrAbove",
"schema_validation.0.data": "",
"practice_type": "WebAPI",
"default": "false",
"ips.0.medium_confidence": "Prevent",
"schema_validation.0.%": "3",
"category": "ThreatPrevention",
"api_attacks.0.%": "3",
"ips.0.high_confidence": "Prevent",
"api_attacks.0.advanced_setting.0.body_size": "1000000",
"api_attacks.0.advanced_setting.0.url_size": "32768",
"api_attacks.0.advanced_setting.0.header_size": "102400",
"api_attacks.0.advanced_setting.0.%": "6",
"api_attacks.0.advanced_setting.0.max_object_depth": "40",
"api_attacks.0.advanced_setting.0.illegal_http_methods": "false",
}),
resource.TestCheckResourceAttrSet(resourceName, "id"),
resource.TestCheckResourceAttrSet(resourceName, "schema_validation.0.id"),
Expand Down Expand Up @@ -131,21 +131,21 @@ func TestAccWebAPIPracticeFull(t *testing.T) {
Config: webAPIPracticeFullConfig(nameAttribute, schemaValidationFilename, schemaValidationData),
Check: resource.ComposeTestCheckFunc(
append(acctest.ComposeTestCheckResourceAttrsFromMap(resourceName, map[string]string{
"name": nameAttribute,
//"schema_validation.0.filename": schemaValidationFilename,
"schema_validation.0.data": schemaValidationData,
"api_attacks.0.minimum_severity": "Critical",
"ips.0.high_confidence": "Detect",
"practice_type": "WebAPI",
//"api_attacks.0.advanced_setting.0.url_size": "1000",
//"api_attacks.0.advanced_setting.0.%": "6",
"ips.0.medium_confidence": "Detect",
"ips.0.performance_impact": "LowOrLower",
//"api_attacks.0.advanced_setting.0.header_size": "1000",
//"api_attacks.0.advanced_setting.0.illegal_http_methods": "true",
//"api_attacks.0.advanced_setting.0.body_size": "1000",
"schema_validation.#": "1",
//"api_attacks.0.advanced_setting.0.max_object_depth": "1000",
"name": nameAttribute,
"schema_validation.0.filename": schemaValidationFilename,
"schema_validation.0.data": schemaValidationData,
"api_attacks.0.minimum_severity": "Critical",
"ips.0.high_confidence": "Detect",
"practice_type": "WebAPI",
"api_attacks.0.advanced_setting.0.url_size": "1000",
"api_attacks.0.advanced_setting.0.%": "6",
"ips.0.medium_confidence": "Detect",
"ips.0.performance_impact": "LowOrLower",
"api_attacks.0.advanced_setting.0.header_size": "1000",
"api_attacks.0.advanced_setting.0.illegal_http_methods": "true",
"api_attacks.0.advanced_setting.0.body_size": "1000",
"schema_validation.#": "1",
"api_attacks.0.advanced_setting.0.max_object_depth": "1000",
"default": "false",
"api_attacks.0.advanced_setting.#": "1",
"category": "ThreatPrevention",
Expand Down Expand Up @@ -263,10 +263,8 @@ resource "inext_web_api_practice" %[1]q {
}
}
schema_validation {
oas_schema {
name = %[2]q
data = %[3]q
}
filename = %[2]q
data = %[3]q
}
}
`, name, filename, data)
Expand Down Expand Up @@ -295,10 +293,8 @@ resource "inext_web_api_practice" %[1]q {
}
}
schema_validation {
oas_schema {
name = %[2]q
data = %[3]q
}
filename = %[2]q
data = %[3]q
}
}
`, name, filename, data)
Expand Down Expand Up @@ -327,10 +323,8 @@ resource "inext_web_api_practice" %[1]q {
}
}
schema_validation {
oas_schema {
name = %[2]q
data = %[3]q
}
filename = %[2]q
data = %[3]q
}
}
`, name, filename, data)
Expand Down
60 changes: 30 additions & 30 deletions internal/resources/web-api-practice.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,37 +172,37 @@ func ResourceWebAPIPractice() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
//"filename": {
// Type: schema.TypeString,
// Required: true,
//},
//"data": {
// Type: schema.TypeString,
// Sensitive: true,
// Required: true,
//},
"oas_schema": {
Type: schema.TypeSet,
Computed: true,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"data": {
Type: schema.TypeString,
Sensitive: true,
Required: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
"size": {
Type: schema.TypeInt,
Required: true,
},
},
},
"filename": {
Type: schema.TypeString,
Required: true,
},
"data": {
Type: schema.TypeString,
Sensitive: true,
Required: true,
},
//"oas_schema": {
// Type: schema.TypeSet,
// Computed: true,
// Optional: true,
// Elem: &schema.Resource{
// Schema: map[string]*schema.Schema{
// "data": {
// Type: schema.TypeString,
// Sensitive: true,
// Required: true,
// },
// "name": {
// Type: schema.TypeString,
// Required: true,
// },
// "size": {
// Type: schema.TypeInt,
// Required: true,
// },
// },
// },
//},
},
},
},
Expand Down
Loading

0 comments on commit 32666aa

Please sign in to comment.