github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/internal/adapters/arm/storage/adapt_test.go (about)

     1  package storage
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/khulnasoft-lab/defsec/pkg/scanners/azure"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"github.com/khulnasoft-lab/defsec/pkg/types"
    11  
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func Test_AdaptStorageDefaults(t *testing.T) {
    16  
    17  	input := azure.Deployment{
    18  		Resources: []azure.Resource{
    19  			{
    20  				Type:       azure.NewValue("Microsoft.Storage/storageAccounts", types.NewTestMetadata()),
    21  				Properties: azure.NewValue(map[string]azure.Value{}, types.NewTestMetadata()),
    22  			},
    23  		},
    24  	}
    25  
    26  	output := Adapt(input)
    27  
    28  	require.Len(t, output.Accounts, 1)
    29  
    30  	account := output.Accounts[0]
    31  	assert.Equal(t, "TLS1_0", account.MinimumTLSVersion.Value())
    32  	assert.Equal(t, false, account.EnforceHTTPS.Value())
    33  
    34  }
    35  
    36  func Test_AdaptStorage(t *testing.T) {
    37  
    38  	input := azure.Deployment{
    39  		Resources: []azure.Resource{
    40  			{
    41  				Type: azure.NewValue("Microsoft.Storage/storageAccounts", types.NewTestMetadata()),
    42  				Name: azure.Value{},
    43  				Properties: azure.NewValue(map[string]azure.Value{
    44  					"minimumTlsVersion":        azure.NewValue("TLS1_2", types.NewTestMetadata()),
    45  					"supportsHttpsTrafficOnly": azure.NewValue(true, types.NewTestMetadata()),
    46  				}, types.NewTestMetadata()),
    47  			},
    48  		},
    49  	}
    50  
    51  	output := Adapt(input)
    52  
    53  	require.Len(t, output.Accounts, 1)
    54  
    55  	account := output.Accounts[0]
    56  	assert.Equal(t, "TLS1_2", account.MinimumTLSVersion.Value())
    57  	assert.Equal(t, true, account.EnforceHTTPS.Value())
    58  
    59  }