From 4d81b869bc86f84845be9eb5a694f31b13376951 Mon Sep 17 00:00:00 2001 From: hedgehog Date: Tue, 28 Feb 2012 08:15:25 +1100 Subject: [PATCH] strip ARNs - AWS is sensitive to leading and trailing whitespace/cr/lf. --- lib/fog/aws/models/elasticache/cluster.rb | 2 +- lib/fog/aws/parsers/sns/confirm_subscription.rb | 2 +- lib/fog/aws/parsers/sns/create_topic.rb | 2 +- lib/fog/aws/parsers/sns/list_subscriptions.rb | 4 ++-- lib/fog/aws/parsers/sns/list_topics.rb | 2 +- lib/fog/aws/parsers/sns/subscribe.rb | 2 +- lib/fog/aws/parsers/sts/get_session_token.rb | 2 +- lib/fog/aws/requests/elasticache/create_cache_cluster.rb | 4 ++-- lib/fog/aws/requests/elasticache/modify_cache_cluster.rb | 4 ++-- lib/fog/aws/requests/iam/create_group.rb | 4 ++-- lib/fog/aws/requests/iam/create_user.rb | 2 +- lib/fog/aws/requests/iam/list_groups.rb | 2 +- lib/fog/aws/requests/iam/list_groups_for_user.rb | 2 +- lib/fog/aws/requests/iam/list_users.rb | 2 +- lib/fog/aws/requests/sns/confirm_subscription.rb | 2 +- lib/fog/aws/requests/sns/delete_topic.rb | 2 +- lib/fog/aws/requests/sns/get_topic_attributes.rb | 2 +- lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb | 2 +- lib/fog/aws/requests/sns/publish.rb | 2 +- lib/fog/aws/requests/sns/set_topic_attributes.rb | 2 +- lib/fog/aws/requests/sns/subscribe.rb | 2 +- lib/fog/aws/requests/sns/unsubscribe.rb | 2 +- 22 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/fog/aws/models/elasticache/cluster.rb b/lib/fog/aws/models/elasticache/cluster.rb index 488393ca1..fde07058a 100644 --- a/lib/fog/aws/models/elasticache/cluster.rb +++ b/lib/fog/aws/models/elasticache/cluster.rb @@ -53,7 +53,7 @@ module Fog :auto_minor_version_upgrade => auto_upgrade, :engine => engine, :engine_version => engine_version, - :notification_topic_arn => notification_config['TopicArn'], + :notification_topic_arn => (notification_config['TopicArn']).strip, :port => port, :preferred_availablility_zone => zone, :preferred_maintenance_window => maintenance_window, diff --git a/lib/fog/aws/parsers/sns/confirm_subscription.rb b/lib/fog/aws/parsers/sns/confirm_subscription.rb index 15631cc51..dc9c95bd5 100644 --- a/lib/fog/aws/parsers/sns/confirm_subscription.rb +++ b/lib/fog/aws/parsers/sns/confirm_subscription.rb @@ -12,7 +12,7 @@ module Fog def end_element(name) case name when 'SubscriptionArn', 'RequestId' - @response[name] = @value.rstrip + @response[name] = @value.strip end end diff --git a/lib/fog/aws/parsers/sns/create_topic.rb b/lib/fog/aws/parsers/sns/create_topic.rb index ee842d399..a037cec44 100644 --- a/lib/fog/aws/parsers/sns/create_topic.rb +++ b/lib/fog/aws/parsers/sns/create_topic.rb @@ -12,7 +12,7 @@ module Fog def end_element(name) case name when 'TopicArn', 'RequestId' - @response[name] = @value.rstrip + @response[name] = @value.strip end end diff --git a/lib/fog/aws/parsers/sns/list_subscriptions.rb b/lib/fog/aws/parsers/sns/list_subscriptions.rb index 07424a680..b19c9c925 100644 --- a/lib/fog/aws/parsers/sns/list_subscriptions.rb +++ b/lib/fog/aws/parsers/sns/list_subscriptions.rb @@ -13,12 +13,12 @@ module Fog def end_element(name) case name when "TopicArn", "Protocol", "SubscriptionArn", "Owner", "Endpoint" - @subscription[name] = @value.rstrip + @subscription[name] = @value.strip when "member" @response['Subscriptions'] << @subscription @subscription = {} when 'RequestId', 'NextToken' - @response[name] = @value.rstrip + @response[name] = @value.strip end end end diff --git a/lib/fog/aws/parsers/sns/list_topics.rb b/lib/fog/aws/parsers/sns/list_topics.rb index efef64c6a..b3df3fb89 100644 --- a/lib/fog/aws/parsers/sns/list_topics.rb +++ b/lib/fog/aws/parsers/sns/list_topics.rb @@ -12,7 +12,7 @@ module Fog def end_element(name) case name when 'TopicArn' - @response['Topics'] << @value + @response['Topics'] << @value.strip when 'NextToken', 'RequestId' response[name] = @value end diff --git a/lib/fog/aws/parsers/sns/subscribe.rb b/lib/fog/aws/parsers/sns/subscribe.rb index 8f209daa0..c0b77a737 100644 --- a/lib/fog/aws/parsers/sns/subscribe.rb +++ b/lib/fog/aws/parsers/sns/subscribe.rb @@ -12,7 +12,7 @@ module Fog def end_element(name) case name when 'SubscriptionArn', 'RequestId' - @response[name] = @value.rstrip + @response[name] = @value.strip end end diff --git a/lib/fog/aws/parsers/sts/get_session_token.rb b/lib/fog/aws/parsers/sts/get_session_token.rb index ee5947386..33a145503 100644 --- a/lib/fog/aws/parsers/sts/get_session_token.rb +++ b/lib/fog/aws/parsers/sts/get_session_token.rb @@ -15,7 +15,7 @@ module Fog when 'SessionToken', 'SecretAccessKey', 'Expiration', 'AccessKeyId' @response[name] = @value.strip when 'Arn', 'FederatedUserId' - @response[name] = @value + @response[name] = @value.strip when 'PackedPolicySize' @response[name] = @value when 'RequestId' diff --git a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb index 6ac85f7f9..a41786034 100644 --- a/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +++ b/lib/fog/aws/requests/elasticache/create_cache_cluster.rb @@ -36,14 +36,14 @@ module Fog # Merge the Cache Security Group parameters with the normal options request(sec_group_params.merge( 'Action' => 'CreateCacheCluster', - 'CacheClusterId' => id, + 'CacheClusterId' => id.strip, 'CacheNodeType' => options[:node_type] || 'cache.m1.large', 'Engine' => options[:engine] || 'memcached', 'NumCacheNodes' => options[:num_nodes] || 1, 'AutoMinorVersionUpgrade' => options[:auto_minor_version_upgrade], 'CacheParameterGroupName' => options[:parameter_group_name], 'EngineVersion' => options[:engine_version], - 'NotificationTopicArn' => options[:notification_topic_arn], + 'NotificationTopicArn' => (options[:notification_topic_arn]).strip, 'Port' => options[:port], 'PreferredAvailabilityZone' => options[:preferred_availablility_zone], 'PreferredMaintenanceWindow' => options[:preferred_maintenance_window], diff --git a/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb b/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb index 318cb2a8a..1f5e8526f 100644 --- a/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb +++ b/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb @@ -45,13 +45,13 @@ module Fog # Merge the Cache Security Group parameters with the normal options request(node_id_params.merge(sec_group_params.merge( 'Action' => 'ModifyCacheCluster', - 'CacheClusterId' => id, + 'CacheClusterId' => id.strip, 'ApplyImmediately' => options[:apply_immediately], 'NumCacheNodes' => options[:num_nodes], 'AutoMinorVersionUpgrade' => options[:auto_minor_version_upgrade], 'CacheParameterGroupName' => options[:parameter_group_name], 'EngineVersion' => options[:engine_version], - 'NotificationTopicArn' => options[:notification_topic_arn], + 'NotificationTopicArn' => (options[:notification_topic_arn]).strip, 'NotificationTopicStatus' => options[:notification_topic_status], 'PreferredMaintenanceWindow' => options[:preferred_maintenance_window], :parser => Fog::Parsers::AWS::Elasticache::SingleCacheCluster.new diff --git a/lib/fog/aws/requests/iam/create_group.rb b/lib/fog/aws/requests/iam/create_group.rb index 4e941e462..e28eb7dba 100644 --- a/lib/fog/aws/requests/iam/create_group.rb +++ b/lib/fog/aws/requests/iam/create_group.rb @@ -44,10 +44,10 @@ module Fog data[:groups][group_name][:path] = path Excon::Response.new.tap do |response| response.body = { 'Group' => { - 'GroupId' => data[:groups][group_name][:group_id], + 'GroupId' => (data[:groups][group_name][:group_id]).strip, 'GroupName' => group_name, 'Path' => path, - 'Arn' => data[:groups][group_name][:arn] }, + 'Arn' => (data[:groups][group_name][:arn]).strip }, 'RequestId' => Fog::AWS::Mock.request_id } response.status = 200 end diff --git a/lib/fog/aws/requests/iam/create_user.rb b/lib/fog/aws/requests/iam/create_user.rb index 97f44a6ae..b063d7e33 100644 --- a/lib/fog/aws/requests/iam/create_user.rb +++ b/lib/fog/aws/requests/iam/create_user.rb @@ -47,7 +47,7 @@ module Fog "UserId" => data[:users][user_name][:user_id], "Path" => path, "UserName" => user_name, - "Arn" => data[:users][user_name][:arn] + "Arn" => (data[:users][user_name][:arn]).strip }, 'RequestId' => Fog::AWS::Mock.request_id } diff --git a/lib/fog/aws/requests/iam/list_groups.rb b/lib/fog/aws/requests/iam/list_groups.rb index 3936ed16d..fd46fc994 100644 --- a/lib/fog/aws/requests/iam/list_groups.rb +++ b/lib/fog/aws/requests/iam/list_groups.rb @@ -48,7 +48,7 @@ module Fog { 'GroupId' => group[:group_id], 'GroupName' => name, 'Path' => group[:path], - 'Arn' => group[:arn] } + 'Arn' => (group[:arn]).strip } end, 'IsTruncated' => false, 'RequestId' => Fog::AWS::Mock.request_id } diff --git a/lib/fog/aws/requests/iam/list_groups_for_user.rb b/lib/fog/aws/requests/iam/list_groups_for_user.rb index 42f54eacb..e86969c37 100644 --- a/lib/fog/aws/requests/iam/list_groups_for_user.rb +++ b/lib/fog/aws/requests/iam/list_groups_for_user.rb @@ -51,7 +51,7 @@ module Fog { 'GroupId' => group[:group_id], 'GroupName' => name, 'Path' => group[:path], - 'Arn' => group[:arn] } + 'Arn' => (group[:arn]).strip } end, 'IsTruncated' => false, 'RequestId' => Fog::AWS::Mock.request_id diff --git a/lib/fog/aws/requests/iam/list_users.rb b/lib/fog/aws/requests/iam/list_users.rb index 1c18d1b0d..870adbaf3 100644 --- a/lib/fog/aws/requests/iam/list_users.rb +++ b/lib/fog/aws/requests/iam/list_users.rb @@ -46,7 +46,7 @@ module Fog { 'UserId' => data[:user_id], 'Path' => data[:path], 'UserName' => user, - 'Arn' => data[:arn] } + 'Arn' => (data[:arn]).strip } end, 'IsTruncated' => false, 'RequestId' => Fog::AWS::Mock.request_id } diff --git a/lib/fog/aws/requests/sns/confirm_subscription.rb b/lib/fog/aws/requests/sns/confirm_subscription.rb index 862f2d97e..a0c3e5e48 100644 --- a/lib/fog/aws/requests/sns/confirm_subscription.rb +++ b/lib/fog/aws/requests/sns/confirm_subscription.rb @@ -21,7 +21,7 @@ module Fog request({ 'Action' => 'ConfirmSubscription', 'Token' => token, - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::ConfirmSubscription.new }.merge!(options)) end diff --git a/lib/fog/aws/requests/sns/delete_topic.rb b/lib/fog/aws/requests/sns/delete_topic.rb index c5b71a865..52a06fabd 100644 --- a/lib/fog/aws/requests/sns/delete_topic.rb +++ b/lib/fog/aws/requests/sns/delete_topic.rb @@ -17,7 +17,7 @@ module Fog def delete_topic(arn) request({ 'Action' => 'DeleteTopic', - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::DeleteTopic.new }) end diff --git a/lib/fog/aws/requests/sns/get_topic_attributes.rb b/lib/fog/aws/requests/sns/get_topic_attributes.rb index 34a3336f7..e9cd881d5 100644 --- a/lib/fog/aws/requests/sns/get_topic_attributes.rb +++ b/lib/fog/aws/requests/sns/get_topic_attributes.rb @@ -17,7 +17,7 @@ module Fog def get_topic_attributes(arn) request({ 'Action' => 'GetTopicAttributes', - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::GetTopicAttributes.new }) end diff --git a/lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb b/lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb index 7b19df2ed..cc078d8a6 100644 --- a/lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb +++ b/lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb @@ -19,7 +19,7 @@ module Fog def list_subscriptions_by_topic(arn, options = {}) request({ 'Action' => 'ListSubscriptionsByTopic', - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new }.merge!(options)) end diff --git a/lib/fog/aws/requests/sns/publish.rb b/lib/fog/aws/requests/sns/publish.rb index 790d5e44d..f87176659 100644 --- a/lib/fog/aws/requests/sns/publish.rb +++ b/lib/fog/aws/requests/sns/publish.rb @@ -22,7 +22,7 @@ module Fog request({ 'Action' => 'Publish', 'Message' => message, - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Publish.new }.merge!(options)) end diff --git a/lib/fog/aws/requests/sns/set_topic_attributes.rb b/lib/fog/aws/requests/sns/set_topic_attributes.rb index 99f4e2d6f..8e30a8994 100644 --- a/lib/fog/aws/requests/sns/set_topic_attributes.rb +++ b/lib/fog/aws/requests/sns/set_topic_attributes.rb @@ -21,7 +21,7 @@ module Fog 'Action' => 'SetTopicAttributes', 'AttributeName' => attribute_name, 'AttributeValue' => attribute_value, - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::SetTopicAttributes.new }) end diff --git a/lib/fog/aws/requests/sns/subscribe.rb b/lib/fog/aws/requests/sns/subscribe.rb index 91beec446..ede9de2d5 100644 --- a/lib/fog/aws/requests/sns/subscribe.rb +++ b/lib/fog/aws/requests/sns/subscribe.rb @@ -21,7 +21,7 @@ module Fog 'Action' => 'Subscribe', 'Endpoint' => endpoint, 'Protocol' => protocol, - 'TopicArn' => arn, + 'TopicArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Subscribe.new }) end diff --git a/lib/fog/aws/requests/sns/unsubscribe.rb b/lib/fog/aws/requests/sns/unsubscribe.rb index 29ca5df73..0a990db3a 100644 --- a/lib/fog/aws/requests/sns/unsubscribe.rb +++ b/lib/fog/aws/requests/sns/unsubscribe.rb @@ -17,7 +17,7 @@ module Fog def unsubscribe(arn) request({ 'Action' => 'Unsubscribe', - 'SubscriptionArn' => arn, + 'SubscriptionArn' => arn.strip, :parser => Fog::Parsers::AWS::SNS::Unsubscribe.new }) end