Files
trivy/pkg/iac/adapters/arm/appservice/adapt_test.go
yagreut c6d95d7cd2 feat(misconf): Update AppService schema (#9792)
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
Co-authored-by: Nikita Pivkin <nikita.pivkin@smartforce.io>
2025-11-19 07:21:09 +00:00

90 lines
2.0 KiB
Go

package appservice
import (
"testing"
"github.com/aquasecurity/trivy/pkg/iac/adapters/arm/adaptertest"
"github.com/aquasecurity/trivy/pkg/iac/providers/azure/appservice"
"github.com/aquasecurity/trivy/pkg/iac/types"
)
func TestAdapt(t *testing.T) {
tests := []struct {
name string
source string
expected appservice.AppService
}{
{
name: "empty",
source: `{
"resources": [
{
"type": "Microsoft.Web/sites",
"properties": {}
}
]
}`,
expected: appservice.AppService{
Services: []appservice.Service{{}},
FunctionApps: []appservice.FunctionApp{{}},
},
},
{
name: "complete",
source: `{
"resources": [
{
"type": "Microsoft.Web/sites",
"properties": {
"httpsOnly": true,
"clientCertEnabled": true,
"identity": {
"type": "SystemAssigned"
},
"siteAuthSettings": {
"enabled": true
},
"minTlsVersion": "1.3",
"siteConfig": {
"http20Enabled": true,
"minTlsVersion": "1.2",
"phpVersion": "8.1",
"pythonVersion": "3.11",
"ftpsState": "FtpsOnly"
}
}
}
]
}`,
expected: appservice.AppService{
Services: []appservice.Service{{
EnableClientCert: types.BoolTest(true),
HTTPSOnly: types.BoolTest(true),
Identity: appservice.Identity{
Type: types.StringTest("SystemAssigned"),
},
Authentication: appservice.Authentication{
Enabled: types.BoolTest(true),
},
Site: appservice.Site{
EnableHTTP2: types.BoolTest(true),
MinimumTLSVersion: types.StringTest("1.2"),
PHPVersion: types.StringTest("8.1"),
PythonVersion: types.StringTest("3.11"),
FTPSState: types.StringTest("FtpsOnly"),
},
}},
FunctionApps: []appservice.FunctionApp{{
HTTPSOnly: types.BoolTest(true),
}},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
adaptertest.AdaptAndCompare(t, tt.source, tt.expected, Adapt)
})
}
}