mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			128 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			128 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
/*
 | 
						|
Copyright 2017 The Kubernetes Authors.
 | 
						|
 | 
						|
Licensed under the Apache License, Version 2.0 (the "License");
 | 
						|
you may not use this file except in compliance with the License.
 | 
						|
You may obtain a copy of the License at
 | 
						|
 | 
						|
    http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
 | 
						|
Unless required by applicable law or agreed to in writing, software
 | 
						|
distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
See the License for the specific language governing permissions and
 | 
						|
limitations under the License.
 | 
						|
*/
 | 
						|
 | 
						|
package aws
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/aws/aws-sdk-go/aws"
 | 
						|
	"testing"
 | 
						|
)
 | 
						|
 | 
						|
func TestElbProtocolsAreEqual(t *testing.T) {
 | 
						|
	grid := []struct {
 | 
						|
		L        *string
 | 
						|
		R        *string
 | 
						|
		Expected bool
 | 
						|
	}{
 | 
						|
		{
 | 
						|
			L:        aws.String("http"),
 | 
						|
			R:        aws.String("http"),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String("HTTP"),
 | 
						|
			R:        aws.String("http"),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String("HTTP"),
 | 
						|
			R:        aws.String("TCP"),
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String(""),
 | 
						|
			R:        aws.String("TCP"),
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String(""),
 | 
						|
			R:        aws.String(""),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        nil,
 | 
						|
			R:        aws.String(""),
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String(""),
 | 
						|
			R:        nil,
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        nil,
 | 
						|
			R:        nil,
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
	}
 | 
						|
	for _, g := range grid {
 | 
						|
		actual := elbProtocolsAreEqual(g.L, g.R)
 | 
						|
		if actual != g.Expected {
 | 
						|
			t.Errorf("unexpected result from protocolsEquals(%v, %v)", g.L, g.R)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func TestAWSARNEquals(t *testing.T) {
 | 
						|
	grid := []struct {
 | 
						|
		L        *string
 | 
						|
		R        *string
 | 
						|
		Expected bool
 | 
						|
	}{
 | 
						|
		{
 | 
						|
			L:        aws.String("arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"),
 | 
						|
			R:        aws.String("arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String("ARN:AWS:ACM:US-EAST-1:123456789012:CERTIFICATE/12345678-1234-1234-1234-123456789012"),
 | 
						|
			R:        aws.String("arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String("arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"),
 | 
						|
			R:        aws.String(""),
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String(""),
 | 
						|
			R:        aws.String(""),
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        nil,
 | 
						|
			R:        aws.String(""),
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        aws.String(""),
 | 
						|
			R:        nil,
 | 
						|
			Expected: false,
 | 
						|
		},
 | 
						|
		{
 | 
						|
			L:        nil,
 | 
						|
			R:        nil,
 | 
						|
			Expected: true,
 | 
						|
		},
 | 
						|
	}
 | 
						|
	for _, g := range grid {
 | 
						|
		actual := awsArnEquals(g.L, g.R)
 | 
						|
		if actual != g.Expected {
 | 
						|
			t.Errorf("unexpected result from awsArnEquals(%v, %v)", g.L, g.R)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |