This makes the --azure-open-port flag behave like --amazonec2-open-port flag, enabling the user to provide a protocol for the port, in the format port/protocol. Signed-off-by: André Carvalho <andre.carvalho@corp.globo.com>
32 lines
629 B
Go
32 lines
629 B
Go
package azure
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/Azure/azure-sdk-for-go/arm/network"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseSecurityRuleProtocol(t *testing.T) {
|
|
tests := []struct {
|
|
raw string
|
|
expectedProto network.SecurityRuleProtocol
|
|
expectedErr bool
|
|
}{
|
|
{"tcp", network.TCP, false},
|
|
{"udp", network.UDP, false},
|
|
{"*", network.Asterisk, false},
|
|
{"Invalid", "", true},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
proto, err := parseSecurityRuleProtocol(tc.raw)
|
|
assert.Equal(t, tc.expectedProto, proto)
|
|
if tc.expectedErr {
|
|
assert.Error(t, err)
|
|
} else {
|
|
assert.NoError(t, err)
|
|
}
|
|
}
|
|
}
|