fog-google 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60125d11954dd919a8685781db294ef96edcc0fc
4
- data.tar.gz: 7df579f5e21c306d18112e12bad9e038b6a92b75
3
+ metadata.gz: 0dc1f39d88b02301c3862a372a55a6086209a845
4
+ data.tar.gz: 756283b7749001656eb11ecebdf31bf3417796de
5
5
  SHA512:
6
- metadata.gz: 365da53d78669fe0d8c9d50fe81b10a9cf759152ea11b282ec452e15d7a292360b35f36b187df9a5dc0e47255886a8c8a954d521ad05991371c9189e711d165d
7
- data.tar.gz: a2e8e2812ee8f084805858eee655d89ba10400e3c8585e3066dfbce7b4fc8ea1286c28cd8ac65095ebf4df86ff32dd9564bb5924fceb1a00536b0d78e99b1176
6
+ metadata.gz: 021a04a4a181e6ad9853c5f76ba17ad8dbceb2a1792b7b3708331ed1fe006d68b68f6e44bc0ea564fcc383dd64f94298671aeb910baf25cb5d09ad8537b49ae0
7
+ data.tar.gz: 18c9ff430a290e8f226aeb7f28f00f81a07eb9fbf05e266fd7388062d8b741d2d3f70abf130f493bfa08b1baadb05b4fe709586363c106de662c13818e4cc352
data/README.md CHANGED
@@ -6,6 +6,9 @@ The main maintainers for the Google sections are @icco, @Temikus and @plribeiro3
6
6
 
7
7
  **As of v0.1.1, Google no longer supports Ruby versions less than 2.0.0.**
8
8
 
9
+ **Currently, `fog-google` does not support versions of `google-api-client` >= 0.9 or <= 0.8.5.**
10
+
11
+
9
12
  ## Storage
10
13
 
11
14
  There are two ways to access [Google Cloud Storage](https://cloud.google.com/storage/). The old S3 API and the new JSON API. `Fog::Storage::Google` will automatically direct you to the appropriate API based on the credentials you provide it.
@@ -250,7 +250,7 @@ module Fog
250
250
  "fingerprint" => "5_hasd_gC3E=",
251
251
  "items" => [
252
252
  {
253
- "key" => "sshKeys",
253
+ "key" => "ssh-keys",
254
254
  "value" => "sysadmin:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA1zc7mx+0H8Roywet/L0aVX6MUdkDfzd/17kZhprAbpUXYOILv9AG4lIzQk6xGxDIltghytjfVGme/4A42Sb0Z9LN0pxB4KnWTNoOSHPJtp6jbXpq6PdN9r3Z5NKQg0A/Tfw7gt2N0GDsj6vpK8VbHHdW78JAVUxql18ootJxjaksdocsiHNK8iA6/v9qiLRhX3fOgtK7KpxxdZxLRzFg9vkp8jcGISgpZt27kOgXWhR5YLhi8pRJookzphO5O4yhflgoHoAE65XkfrsRCe0HU5QTbY2jH88rBVkq0KVlZh/lEsuwfmG4d77kEqaCGGro+j1Wrvo2K3DSQ+rEcvPp2CYRUySjhaeLF18UzQLtxNeoN14QOYqlm9ITdkCnmq5w4Wn007MjSOFp8LEq2RekrnddGXjg1/vgmXtaVSGzJAlXwtVfZor3dTRmF0JCpr7DsiupBaDFtLUlGFFlSKmPDVMPOOB5wajexmcvSp2Vu4U3yP8Lai/9/ZxMdsGPhpdCsWVL83B5tF4oYj1HVIycbYIxIIfFqOxZcCru3CMfe9jmzKgKLv2UtkfOS8jpS/Os2gAiB3wPweH3agvtwYAYBVMDwt5cnrhgHYWoOz7ABD8KgmCrD7Y9HikiCqIUNkgUFd9YmjcYi5FkU5rFXIawN7efs341lsdf923lsdf923fs= johndoe@acme"
255
255
  }
256
256
  ]
@@ -162,9 +162,17 @@ module Fog
162
162
  data.body["contents"]
163
163
  end
164
164
 
165
- def set_disk_auto_delete(auto_delete, device_name)
165
+ def set_disk_auto_delete(auto_delete, device_name = nil)
166
166
  requires :identity, :zone
167
167
 
168
+ unless device_name
169
+ if disks.count <= 1
170
+ device_name = disks[0]["deviceName"]
171
+ else
172
+ raise ArgumentError.new("Device name required if multiple disks are attached")
173
+ end
174
+ end
175
+
168
176
  data = service.set_server_disk_auto_delete(identity, zone_name, auto_delete, device_name)
169
177
  Fog::Compute::Google::Operations.new(:service => service).get(data.body["name"], data.body["zone"])
170
178
  end
@@ -201,13 +209,17 @@ module Fog
201
209
  def add_ssh_key(username, key)
202
210
  self.metadata = Hash.new("") if metadata.nil?
203
211
 
212
+ # The key "sshKeys" is deprecated and will be unsupported in the
213
+ # future - for now defer to using 'ssh-keys' unless the user is
214
+ # already using the deprecated version
215
+ # https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#deprecated
216
+ metadata_key = metadata.key?("sshKeys") ? "sshKeys" : "ssh-keys"
217
+
204
218
  # You can have multiple SSH keys, seperated by newlines.
205
219
  # https://developers.google.com/compute/docs/console?hl=en#sshkeys
206
- metadata["sshKeys"] = "" unless metadata["sshKeys"]
207
-
208
- metadata["sshKeys"] += "\n" unless metadata["sshKeys"].empty?
209
-
210
- metadata["sshKeys"] += "#{username}:#{key.strip}"
220
+ metadata[metadata_key] = "" unless metadata[metadata_key]
221
+ metadata[metadata_key] += "\n" unless metadata[metadata_key].empty?
222
+ metadata[metadata_key] += "#{username}:#{key.strip}"
211
223
 
212
224
  metadata
213
225
  end
@@ -73,8 +73,16 @@ module Fog
73
73
  reload
74
74
  end
75
75
 
76
- def get_health
77
- service.get_target_pool_health self
76
+ def get_health(instance_name = nil)
77
+ if instance_name
78
+ instance = service.servers.get(instance_name)
79
+ health_results = [service.get_target_pool_health(self, instance.self_link)]
80
+ else
81
+ health_results = instances.map do |instance_selflink|
82
+ service.get_target_pool_health(self, instance_selflink)
83
+ end
84
+ end
85
+ Hash[health_results]
78
86
  end
79
87
 
80
88
  def ready?
@@ -2,13 +2,13 @@ module Fog
2
2
  module Compute
3
3
  class Google
4
4
  class Mock
5
- def get_target_pool_health(_target_pool)
5
+ def get_target_pool_health(_target_pool, _instance)
6
6
  Fog::Mock.not_implemented
7
7
  end
8
8
  end
9
9
 
10
10
  class Real
11
- def get_target_pool_health(target_pool)
11
+ def get_target_pool_health(target_pool, instance = nil)
12
12
  api_method = @compute.target_pools.get_health
13
13
  parameters = {
14
14
  "project" => @project,
@@ -16,12 +16,22 @@ module Fog
16
16
  "region" => target_pool.region.split("/")[-1]
17
17
  }
18
18
 
19
- health_results = target_pool.instances.map do |instance|
19
+ if instance
20
20
  body = { "instance" => instance }
21
21
  resp = request(api_method, parameters, body_object = body)
22
22
  [instance, resp.data[:body]["healthStatus"]]
23
+ else
24
+ # TODO: Remove (introduced after 0.4.2)
25
+ Fog::Logger.deprecation(
26
+ "Do not use raw requests, use Fog::Compute::Google::TargetPool.get_health instead [light_black](#{caller.first})[/]"
27
+ )
28
+ health_results = target_pool.instances.map do |instance_object|
29
+ body = { "instance" => instance_object }
30
+ resp = request(api_method, parameters, body_object = body)
31
+ [instance_object, resp.data[:body]["healthStatus"]]
32
+ end
33
+ Hash[health_results]
23
34
  end
24
- Hash[health_results]
25
35
  end
26
36
  end
27
37
  end
@@ -23,6 +23,7 @@ module Fog
23
23
  disks
24
24
  end
25
25
 
26
+ # (see Fog::Compute::Google::Real#insert_server)
26
27
  def insert_server(server_name, zone_name, options = {}, *_deprecated_args)
27
28
  # check that zone exists
28
29
  get_zone(zone_name)
@@ -62,7 +63,7 @@ module Fog
62
63
  "fingerprint" => "5_hasd_gC3E=",
63
64
  "items" => [
64
65
  {
65
- "key" => "sshKeys",
66
+ "key" => "ssh-keys",
66
67
  "value" => "sysadmin:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA1zc7mx+0H8Roywet/L0aVX6MUdkDfzd/17kZhprAbpUXYOILv9AG4lIzQk6xGxDIltghytjfVGme/4A42Sb0Z9LN0pxB4KnWTNoOSHPJtp6jbXpq6PdN9r3Z5NKQg0A/Tfw7gt2N0GDsj6vpK8VbHHdW78JAVUxql18ootJxjaksdocsiHNK8iA6/v9qiLRhX3fOgtK7KpxxdZxLRzFg9vkp8jcGISgpZt27kOgXWhR5YLhi8pRJookzphO5O4yhflgoHoAE65XkfrsRCe0HU5QTbY2jH88rBVkq0KVlZh/lEsuwfmG4d77kEqaCGGro+j1Wrvo2K3DSQ+rEcvPp2CYRUySjhaeLF18UzQLtxNeoN14QOYqlm9ITdkCnmq5w4Wn007MjSOFp8LEq2RekrnddGXjg1/vgmXtaVSGzJAlXwtVfZor3dTRmF0JCpr7DsiupBaDFtLUlGFFlSKmPDVMPOOB5wajexmcvSp2Vu4U3yP8Lai/9/ZxMdsGPhpdCsWVL83B5tF4oYj1HVIycbYIxIIfFqOxZcCru3CMfe9jmzKgKLv2UtkfOS8jpS/Os2gAiB3wPweH3agvtwYAYBVMDwt5cnrhgHYWoOz7ABD8KgmCrD7Y9HikiCqIUNkgUFd9YmjcYi5FkU5rFXIawN7efs341lsdf923lsdf923fs= johndoe@acme"
67
68
  }
68
69
  ]
@@ -113,6 +114,61 @@ module Fog
113
114
  { "items" => metadata.map { |k, v| { "key" => k, "value" => v } } }
114
115
  end
115
116
 
117
+ ##
118
+ # Create a new instance (virtual machine). You can provision a server
119
+ # using low-level request options via this method (if you don't need to
120
+ # modify low-level request options, consider using the 'servers'
121
+ # collection object instead - see Fog::Compute::Google::Servers).
122
+ # This method should directly take any of the API parameters/options for
123
+ # the GCP endpoint (passed through the +options+ parameter).
124
+ #
125
+ # @see https://cloud.google.com/compute/docs/reference/latest/instances/insert
126
+ # @example minimal server creation
127
+ # require 'fog/google'
128
+ # client = Fog::Compute::Google.new
129
+ # my_result = client.insert_server('my-server',
130
+ # 'us-central1-b',
131
+ # 'machineType' => 'f1-micro',
132
+ # 'disks' => [
133
+ # 'initializeParams' => {
134
+ # 'sourceImage' => 'projects/debian-cloud/global/images/family/debian-8'
135
+ # }
136
+ # ])
137
+ #
138
+ # @param server_name [String] Name to assign to the created server. Must
139
+ # be unique within the specified zone.
140
+ # @param zone_name [String] Name of zone containing the created server.
141
+ # See Fog::Compute::Google#zones for a list of available zones.
142
+ # @param options [Hash] options to use when creating a server. You can
143
+ # use any of the options documented at
144
+ # https://cloud.google.com/compute/docs/reference/latest/instances/insert.
145
+ # Additionally accepts some nonstandard parameters documented below.
146
+ # @option options [String] 'machineType' Required: the machine type to use - see
147
+ # https://cloud.google.com/compute/docs/machine-types for a list.
148
+ # @option options [String] 'externalIp' An IP address to assign to the
149
+ # server. See
150
+ # https://cloud.google.com/compute/docs/configure-instance-ip-addresses
151
+ # for more information about assigning instance ip addresses.
152
+ # @option options [Boolean] 'auto_restart' (false) if true, then the
153
+ # server will be automatically restarted if terminated by Google Compute
154
+ # Engine. Note that this value cannot be set to true if the VM is
155
+ # preemptible.
156
+ # @option options [Boolean] 'preemptible' (false) if true, then the
157
+ # created server will be preemptible and therefore only run for at
158
+ # most 24 hours. See
159
+ # https://cloud.google.com/compute/docs/instances/preemptible for more
160
+ # information about preemptible instances.
161
+ # @option options ["MIGRATE", "TERMINATE"] 'on_host_maintenance' if
162
+ # "MIGRATE", then the VM will be migrated to different hardware during
163
+ # a maintenance event. If "TERMINATE", then the VM will be terminated.
164
+ # Note that if the VM is preemptible, then this option MUST be
165
+ # "TERMINATE".
166
+ # @option options [Boolean] 'can_ip_forward' (false) if true, then the
167
+ # created instance will allow forwarding packets that don't originate
168
+ # with the assigned host ip address. See
169
+ # https://cloud.google.com/compute/docs/networking#canipforward for
170
+ # more information.
171
+ # @return [Excon::Response] response object that represents the result.
116
172
  def insert_server(server_name, zone_name, options = {}, *deprecated_args)
117
173
  if deprecated_args.length > 0 || !options.is_a?(Hash)
118
174
  raise ArgumentError.new "Too many parameters specified. This may be the cause of code written for an outdated"\
@@ -29,6 +29,7 @@ module Fog
29
29
  # @option options [String] :app_name The app name to set in the user agent
30
30
  # @option options [String] :app_version The app version to set in the user agent
31
31
  # @option options [Google::APIClient] :google_client Existing Google API Client
32
+ # @option options [Hash] :google_client_options A hash to send adition options to Google API Client
32
33
  # @return [Google::APIClient] Google API Client
33
34
  # @raises [ArgumentError] If there is any missing argument
34
35
  def initialize_google_client(options)
@@ -62,7 +63,8 @@ module Fog
62
63
  signing_key,
63
64
  options[:google_api_scope_url],
64
65
  options[:app_name],
65
- options[:app_version]
66
+ options[:app_version],
67
+ options[:google_client_options]
66
68
  )
67
69
  end
68
70
 
@@ -109,7 +111,7 @@ module Fog
109
111
  # @param [String] app_name The app name to set in the user agent
110
112
  # @param [String] app_version The app version to set in the user agent
111
113
  # @return [Google::APIClient] Google API Client
112
- def new_pk12_google_client(google_client_email, signing_key, google_api_scope_url, app_name = nil, app_version = nil)
114
+ def new_pk12_google_client(google_client_email, signing_key, google_api_scope_url, app_name = nil, app_version = nil, google_client_options = [])
113
115
  application_name = app_name.nil? ? "fog" : "#{app_name}/#{app_version || '0.0.0'} fog"
114
116
  api_client_options = {
115
117
  :application_name => application_name,
@@ -124,7 +126,8 @@ module Fog
124
126
  :issuer => google_client_email,
125
127
  :scope => google_api_scope_url,
126
128
  :signing_key => signing_key,
127
- :token_credential_uri => "https://accounts.google.com/o/oauth2/token"
129
+ :token_credential_uri => "https://accounts.google.com/o/oauth2/token",
130
+ :google_client_options => google_client_options
128
131
  )
129
132
  client.authorization.fetch_access_token!
130
133
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "0.4.2".freeze
3
+ VERSION = "0.5.0".freeze
4
4
  end
5
5
  end
@@ -16,7 +16,7 @@ module Fog
16
16
  :prefix => "prefix")
17
17
  data = service.get_bucket(key, options).body
18
18
  new(:key => data["name"])
19
- rescue Excon::Errors::NotFound
19
+ rescue Fog::Errors::NotFound
20
20
  nil
21
21
  end
22
22
  end
@@ -16,7 +16,7 @@ module Fog
16
16
  requires :key
17
17
  service.delete_bucket(key)
18
18
  true
19
- rescue Excon::Errors::NotFound
19
+ rescue Fog::Errors::NotFound
20
20
  false
21
21
  end
22
22
 
@@ -63,7 +63,7 @@ module Fog
63
63
  requires :directory, :key
64
64
  service.delete_object(directory.key, key)
65
65
  true
66
- rescue Excon::Errors::NotFound
66
+ rescue Fog::Errors::NotFound
67
67
  false
68
68
  end
69
69
 
@@ -47,7 +47,7 @@ module Fog
47
47
  file_data.merge!(:body => data.body,
48
48
  :key => key)
49
49
  new(file_data)
50
- rescue Excon::Errors::NotFound
50
+ rescue Fog::Errors::NotFound
51
51
  nil
52
52
  end
53
53
 
@@ -61,7 +61,7 @@ module Fog
61
61
  data = service.head_object(directory.key, key, options)
62
62
  file_data = data.headers.merge(:key => key)
63
63
  new(file_data)
64
- rescue Excon::Errors::NotFound
64
+ rescue Fog::Errors::NotFound
65
65
  nil
66
66
  end
67
67
 
@@ -54,11 +54,10 @@ module Fog
54
54
 
55
55
  def destroy
56
56
  requires :directory, :key
57
- begin
58
- service.delete_object(directory.key, key)
59
- rescue Excon::Errors::NotFound
60
- end
57
+ service.delete_object(directory.key, key)
61
58
  true
59
+ rescue Excon::Errors::NotFound
60
+ false
62
61
  end
63
62
 
64
63
  remove_method :metadata
@@ -1,7 +1,7 @@
1
1
  require "helpers/integration_test_helper"
2
2
 
3
3
  class TestRegions < FogIntegrationTest
4
- NAMES = %w(asia-east1 europe-west1 us-central1 us-central2)
4
+ NAMES = %w(asia-east1 asia-northeast1 europe-west1 us-central1 us-east1 us-west1).freeze
5
5
 
6
6
  def setup
7
7
  @subject = Fog::Compute[:google].regions
@@ -0,0 +1,166 @@
1
+ require "helpers/integration_test_helper"
2
+ require "securerandom"
3
+ require "base64"
4
+
5
+ class TestPubsubRequests < FogIntegrationTest
6
+ def setup
7
+ @client = Fog::Google::Pubsub.new
8
+ # Ensure any resources we create with test prefixes are removed
9
+ Minitest.after_run do
10
+ delete_test_resources
11
+ end
12
+ end
13
+
14
+ def delete_test_resources
15
+ topics = @client.list_topics[:body]["topics"]
16
+ unless topics.nil?
17
+ topics.
18
+ map { |t| t["name"] }.
19
+ select { |t| t.start_with?(topic_resource_prefix) }.
20
+ each { |t| @client.delete_topic(t) }
21
+ end
22
+
23
+ subscriptions = @client.list_subscriptions[:body]["subscriptions"]
24
+ unless subscriptions.nil?
25
+ subscriptions.
26
+ map { |s| s["name"] }.
27
+ select { |s| s.start_with?(subscription_resource_prefix) }.
28
+ each { |s| @client.delete_subscription(s) }
29
+ end
30
+ end
31
+
32
+ def topic_resource_prefix
33
+ "projects/#{@client.project}/topics/fog-integration-test"
34
+ end
35
+
36
+ def subscription_resource_prefix
37
+ "projects/#{@client.project}/subscriptions/fog-integration-test"
38
+ end
39
+
40
+ def new_topic_name
41
+ "#{topic_resource_prefix}-#{SecureRandom.uuid}"
42
+ end
43
+
44
+ def new_subscription_name
45
+ "#{subscription_resource_prefix}-#{SecureRandom.uuid}"
46
+ end
47
+
48
+ def some_topic_name
49
+ # create lazily to speed tests up
50
+ @some_topic ||= new_topic_name.tap do |t|
51
+ @client.create_topic(t)
52
+ end
53
+ @some_topic
54
+ end
55
+
56
+ def some_subscription_name
57
+ # create lazily to speed tests up
58
+ @some_subscription ||= new_subscription_name.tap do |s|
59
+ @client.create_subscription(s, some_topic_name)
60
+ end
61
+ @some_subscription
62
+ end
63
+
64
+ def test_create_topic
65
+ result = @client.create_topic(new_topic_name)
66
+
67
+ assert_equal(200, result.status, "request should be successful")
68
+ assert_includes(result[:body].keys, "name", "resulting body should contain expected keys")
69
+ end
70
+
71
+ def test_get_topic
72
+ result = @client.get_topic(some_topic_name)
73
+
74
+ assert_equal(200, result.status, "request should be successful")
75
+ assert_includes(result[:body].keys, "name", "resulting body should contain expected keys")
76
+ end
77
+
78
+ def test_list_topics
79
+ # Force a topic to be created just so we have at least 1 to list
80
+ @client.create_topic(new_topic_name)
81
+ result = @client.list_topics
82
+
83
+ assert_equal(200, result.status, "request should be successful")
84
+ assert_includes(result[:body].keys, "topics", "resulting body should contain expected keys")
85
+ assert_operator(result[:body]["topics"].size, :>, 0, "topic count should be positive")
86
+ end
87
+
88
+ def test_delete_topic
89
+ topic_to_delete = new_topic_name
90
+ @client.create_topic(topic_to_delete)
91
+
92
+ result = @client.delete_topic(topic_to_delete)
93
+ assert_equal(200, result.status, "request should be successful")
94
+ end
95
+
96
+ def test_publish_topic
97
+ result = @client.publish_topic(some_topic_name, [:data => Base64.strict_encode64("some message")])
98
+
99
+ assert_equal(200, result.status, "request should be successful")
100
+ assert_includes(result[:body].keys, "messageIds", "resulting body should contain expected keys")
101
+ end
102
+
103
+ def test_create_subscription
104
+ push_config = {}
105
+ ack_deadline_seconds = 18
106
+
107
+ result = @client.create_subscription(new_subscription_name, some_topic_name, push_config, ack_deadline_seconds)
108
+
109
+ assert_equal(200, result.status, "request should be successful")
110
+ assert((%w{name topic pushConfig ackDeadlineSeconds} - result[:body].keys).empty?,
111
+ "resulting body should contain expected keys")
112
+ assert_equal(18, result[:body]["ackDeadlineSeconds"], "ackDeadlineSeconds should be 18")
113
+ end
114
+
115
+ def test_get_subscription
116
+ result = @client.get_subscription(some_subscription_name)
117
+
118
+ assert_equal(200, result.status, "request should be successful")
119
+ assert(%w{name topic pushConfig ackDeadlineSeconds} - result[:body].keys,
120
+ "resulting body should contain expected keys")
121
+ end
122
+
123
+ def test_list_subscriptions
124
+ # Force a subscription to be created just so we have at least 1 to list
125
+ @client.create_subscription(new_subscription_name, some_topic_name)
126
+ result = @client.list_subscriptions
127
+
128
+ assert_equal(200, result.status, "request should be successful")
129
+ assert_includes(result[:body].keys, "subscriptions", "resulting body should contain expected keys")
130
+ assert_operator(result[:body]["subscriptions"].size, :>, 0, "subscription count should be positive")
131
+ end
132
+
133
+ def test_delete_subscription
134
+ subscription_to_delete = new_subscription_name
135
+ @client.create_subscription(subscription_to_delete, some_topic_name)
136
+
137
+ result = @client.delete_subscription(subscription_to_delete)
138
+ assert_equal(200, result.status, "request should be successful")
139
+ end
140
+
141
+ def test_pull_subscription
142
+ subscription = new_subscription_name
143
+ @client.create_subscription(subscription, some_topic_name)
144
+ @client.publish_topic(some_topic_name, [:data => Base64.strict_encode64("some message")])
145
+
146
+ result = @client.pull_subscription(subscription)
147
+
148
+ assert_equal(200, result.status, "request should be successful")
149
+ assert_includes(result[:body].keys, "receivedMessages", "resulting body should contain expected keys")
150
+ assert_equal(1, result[:body]["receivedMessages"].size, "we should have received a message")
151
+ assert_equal("some message",
152
+ Base64.strict_decode64(result[:body]["receivedMessages"][0]["message"]["data"]),
153
+ "received message should be the same as what we sent")
154
+ end
155
+
156
+ def test_acknowledge_subscription
157
+ subscription = new_subscription_name
158
+ @client.create_subscription(subscription, some_topic_name)
159
+ @client.publish_topic(some_topic_name, [:data => Base64.strict_encode64("some message")])
160
+ pull_result = @client.pull_subscription(subscription)
161
+
162
+ result = @client.acknowledge_subscription(subscription, pull_result[:body]["receivedMessages"][0]["ackId"])
163
+
164
+ assert_equal(200, result.status, "request should be successful")
165
+ end
166
+ end
@@ -0,0 +1,20 @@
1
+ require "helpers/test_helper"
2
+ require File.expand_path("../../../../lib/fog/compute/google/models/server", __FILE__)
3
+
4
+ class UnitTestServer < MiniTest::Test
5
+ def test_metadata_uses_deprecated_sshKeys_if_exists
6
+ server = Fog::Compute::Google::Server.new(:metadata => { "sshKeys" => "existing_user:existing_key" })
7
+ server.add_ssh_key("my_username", "my_key")
8
+
9
+ assert_match(/my_username/, server.metadata["sshKeys"])
10
+ assert_match(/my_key/, server.metadata["sshKeys"])
11
+ end
12
+
13
+ def test_add_ssh_key_uses_ssh_keys_by_default
14
+ server = Fog::Compute::Google::Server.new
15
+ server.add_ssh_key("my_username", "my_key")
16
+
17
+ assert_match(/my_username/, server.metadata["ssh-keys"])
18
+ assert_match(/my_key/, server.metadata["ssh-keys"])
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-10-28 00:00:00.000000000 Z
14
+ date: 2016-12-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog-core
@@ -628,11 +628,13 @@ files:
628
628
  - test/integration/factories/target_instances_factory.rb
629
629
  - test/integration/factories/target_pools_factory.rb
630
630
  - test/integration/factories/url_maps_factory.rb
631
+ - test/integration/pubsub/test_pubsub_requests.rb
631
632
  - test/integration/storage/test_buckets.rb
632
633
  - test/integration/storage/test_directories.rb
633
634
  - test/integration/storage/test_files.rb
634
635
  - test/integration/storage/test_objects.rb
635
636
  - test/integration/test_authentication.rb
637
+ - test/unit/compute/test_server.rb
636
638
  - tests/helper.rb
637
639
  - tests/helpers/collection_helper.rb
638
640
  - tests/helpers/compute/flavors_helper.rb
@@ -753,8 +755,10 @@ test_files:
753
755
  - test/integration/factories/target_instances_factory.rb
754
756
  - test/integration/factories/target_pools_factory.rb
755
757
  - test/integration/factories/url_maps_factory.rb
758
+ - test/integration/pubsub/test_pubsub_requests.rb
756
759
  - test/integration/storage/test_buckets.rb
757
760
  - test/integration/storage/test_directories.rb
758
761
  - test/integration/storage/test_files.rb
759
762
  - test/integration/storage/test_objects.rb
760
763
  - test/integration/test_authentication.rb
764
+ - test/unit/compute/test_server.rb