Skip to content

Commit 46fa9df

Browse files
authored
Remove aws region validation (#38)
* Remove aws region validation removed it, as it was causing issue whenever we add a new region * fix test cases * fix
1 parent 74e6883 commit 46fa9df

7 files changed

+2
-80
lines changed

aws_region.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ var AWSRegions = []AWSRegion{
3232

3333
var (
3434
ErrAWSRegionEmptyString = errors.New("Region cannot be empty")
35-
ErrAWSRegionInvalid = errors.New("Region is invalid")
3635
)
3736

3837
func (r *AWSRegion) UnmarshalText(data []byte) error {
@@ -46,12 +45,5 @@ func (r AWSRegion) Validate() error {
4645
return ErrAWSRegionEmptyString
4746
}
4847

49-
if r != AWS_REGION_US_EAST_1 && r != AWS_REGION_US_WEST_1 && r != AWS_REGION_US_WEST_2 && r != AWS_REGION_US_GOV_WEST_1 &&
50-
r != AWS_REGION_EU_WEST_1 && r != AWS_REGION_EU_CENTRAL_1 &&
51-
r != AWS_REGION_AP_SOUTHEAST_1 && r != AWS_REGION_AP_SOUTHEAST_2 && r != AWS_REGION_AP_NORTHEAST_1 &&
52-
r != AWS_REGION_SA_EAST_1 {
53-
return ErrAWSRegionInvalid
54-
}
55-
5648
return nil
5749
}

aws_region_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ func (s *AWSRegionSuite) TestValidateErrorNoRegion() {
3434
assert.Equal(s.T(), ErrAWSRegionEmptyString, err)
3535
}
3636

37-
func (s *AWSRegionSuite) TestValidateErrorInvalidRegion() {
38-
r := AWSRegion("invalidregion")
39-
err := r.Validate()
40-
assert.NotNil(s.T(), err)
41-
assert.Equal(s.T(), ErrAWSRegionInvalid, err)
42-
}
43-
4437
func (s *AWSRegionSuite) TestUnmarshalText() {
4538
r := AWSRegion("")
4639
d := []byte(AWS_REGION_US_EAST_1)
@@ -56,11 +49,3 @@ func (s *AWSRegionSuite) TestUnmarshalErrorNoRegion() {
5649
assert.NotNil(s.T(), err)
5750
assert.Equal(s.T(), ErrAWSRegionEmptyString, err)
5851
}
59-
60-
func (s *AWSRegionSuite) TestUnmarshalErrorInvalidRegion() {
61-
r := AWSRegion("")
62-
d := []byte("invalidregion")
63-
err := r.UnmarshalText(d)
64-
assert.NotNil(s.T(), err)
65-
assert.Equal(s.T(), ErrAWSRegionInvalid, err)
66-
}

remoteconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (s *RemoteConfigSuite) TestValidateConfigWithReflectionErrorSQSQueueConfigV
203203
}
204204
err := validateConfigWithReflection(c)
205205
assert.NotNil(s.T(), err)
206-
assert.Equal(s.T(), errors.New("Sub Field of SQSQueue, failed to validate with error, Validater Field: Region, failed to validate with error, Region is invalid"), err)
206+
assert.Equal(s.T(), errors.New("Sub Field of SQSQueue, failed to validate with error, Field: AWSAccountID, not set"), err)
207207
}
208208

209209
func (s *RemoteConfigSuite) TestValidateConfigWithReflectionErrorDynamoDBTableConfigNotSet() {
@@ -292,7 +292,7 @@ func (s *RemoteConfigSuite) TestValidateConfigWithReflectionErrorDynamoDBClientC
292292

293293
err := validateConfigWithReflection(c)
294294
assert.NotNil(s.T(), err)
295-
assert.Equal(s.T(), errors.New("Sub Field of DynamoDBClient, failed to validate with error, Validater Field: Region, failed to validate with error, Region is invalid"), err)
295+
assert.Equal(s.T(), errors.New("String Field: Str, contains an empty string"), err)
296296
}
297297

298298
func (s *RemoteConfigSuite) TestValidateConfigWithReflectionErrorDynamoDBTableConfigValidate() {

s3_config_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,6 @@ func (s *S3ConfigSuite) TestValidateErrorRegionNotSet() {
111111
s.Equal(errors.New("Field: Region, not set"), err)
112112
}
113113

114-
func (s *S3ConfigSuite) TestValidateErrorRegionInvalid() {
115-
bucket := VALID_S3_CONFIG_BUCKET
116-
region := AWSRegion("invalidregion")
117-
118-
c := &S3Config{
119-
Bucket: &bucket,
120-
Region: &region,
121-
}
122-
123-
err := validateConfigWithReflection(c)
124-
s.NotNil(err)
125-
s.Equal(errors.New("Validater Field: Region, failed to validate with error, Region is invalid"), err)
126-
}
127-
128114
func (s *S3ConfigSuite) TestGetEndpointNotSet() {
129115
bucket := VALID_S3_CONFIG_BUCKET
130116
region := VALID_S3_CONFIG_REGION

sqs_client_config_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ func (s *SQSClientConfigSuite) TestValidateWithEndpoint() {
5151
assert.Nil(s.T(), err)
5252
}
5353

54-
func (s *SQSClientConfigSuite) TestValidateErrorRegion() {
55-
region := AWSRegion("invalidregion")
56-
57-
c := &SQSClientConfig{
58-
Region: &region,
59-
}
60-
61-
err := validateConfigWithReflection(c)
62-
assert.NotNil(s.T(), err)
63-
assert.Equal(s.T(), errors.New("Validater Field: Region, failed to validate with error, Region is invalid"), err)
64-
}
65-
6654
func (s *SQSClientConfigSuite) TestValidateErrorEndpoint() {
6755
region := VALID_SQS_CLIENT_REGION
6856
endpoint := ""

sqs_queue_config_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,6 @@ func (s *SQSQueueConfigSuite) TestValidate() {
5151
assert.Nil(s.T(), err)
5252
}
5353

54-
func (s *SQSQueueConfigSuite) TestValidateErrorRegion() {
55-
region := AWSRegion("invalidregion")
56-
awsAccountID := VALID_SQS_QUEUE_AWS_ACCOUNT_ID
57-
queueName := VALID_SQS_QUEUE_QUEUE_NAME
58-
59-
c := &SQSQueueConfig{
60-
Region: &region,
61-
AWSAccountID: &awsAccountID,
62-
QueueName: &queueName,
63-
}
64-
65-
err := validateConfigWithReflection(c)
66-
assert.NotNil(s.T(), err)
67-
assert.Equal(s.T(), errors.New("Validater Field: Region, failed to validate with error, Region is invalid"), err)
68-
}
69-
7054
func (s *SQSQueueConfigSuite) TestValidateErrorAWSAccountID() {
7155
region := VALID_SQS_QUEUE_REGION
7256
awsAccountID := ""

storage_config_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ func (s *StorageConfigSuite) TestValidateConfigWithReflectionErrorProvider() {
5252
assert.Equal(s.T(), errors.New("Validater Field: StorageConfig, failed to validate with error, Invalid storage provider"), err)
5353
}
5454

55-
func (s *StorageConfigSuite) TestValidateConfigWithReflectionErrorLocation() {
56-
p := VALID_STORAGE_CONFIG_PROVIDER
57-
l := (StorageLocation)("invalid_location")
58-
c := &StorageConfig{
59-
Provider: &p,
60-
Location: &l,
61-
}
62-
63-
err := validateConfigWithReflection(c)
64-
assert.NotNil(s.T(), err)
65-
assert.Equal(s.T(), errors.New("Validater Field: StorageConfig, failed to validate with error, Region is invalid"), err)
66-
}
67-
6855
func (s *StorageConfigSuite) TestGetProvider() {
6956
p := VALID_STORAGE_CONFIG_PROVIDER
7057
c := &StorageConfig{

0 commit comments

Comments
 (0)