Always transform aws_security_group protocol to lower case

fixes #5489
This commit is contained in:
Raphael Randschau 2016-03-07 22:40:29 +01:00
parent 642cf387a3
commit 2c698d2cb0
2 changed files with 26 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log" "log"
"sort" "sort"
"strings"
"time" "time"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
@ -817,7 +818,7 @@ func idHash(rType, protocol string, toPort, fromPort int64, self bool) string {
buf.WriteString(fmt.Sprintf("%s-", rType)) buf.WriteString(fmt.Sprintf("%s-", rType))
buf.WriteString(fmt.Sprintf("%d-", toPort)) buf.WriteString(fmt.Sprintf("%d-", toPort))
buf.WriteString(fmt.Sprintf("%d-", fromPort)) buf.WriteString(fmt.Sprintf("%d-", fromPort))
buf.WriteString(fmt.Sprintf("%s-", protocol)) buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(protocol)))
buf.WriteString(fmt.Sprintf("%t-", self)) buf.WriteString(fmt.Sprintf("%t-", self))
return fmt.Sprintf("rule-%d", hashcode.String(buf.String())) return fmt.Sprintf("rule-%d", hashcode.String(buf.String()))

View File

@ -186,6 +186,30 @@ func TestRulesMixedMatching(t *testing.T) {
}, },
}, },
}, },
// test lower/ uppercase handling
{
local: []interface{}{
map[string]interface{}{
"from_port": 80,
"to_port": 8000,
"protocol": "TCP",
},
},
remote: []map[string]interface{}{
map[string]interface{}{
"from_port": int64(80),
"to_port": int64(8000),
"protocol": "tcp",
},
},
saves: []map[string]interface{}{
map[string]interface{}{
"from_port": 80,
"to_port": 8000,
"protocol": "tcp",
},
},
},
// local and remote differ // local and remote differ
{ {
local: []interface{}{ local: []interface{}{