fog-google 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CONTRIBUTING.md +66 -1
  4. data/CONTRIBUTORS.md +1 -0
  5. data/README.md +24 -7
  6. data/Rakefile +14 -5
  7. data/examples/image_create.rb +1 -1
  8. data/examples/launch_micro_instance.rb +1 -1
  9. data/lib/fog/google/compute.rb +6 -2
  10. data/lib/fog/google/models/compute/addresses.rb +13 -0
  11. data/lib/fog/google/models/compute/backend_services.rb +3 -4
  12. data/lib/fog/google/models/compute/global_forwarding_rules.rb +5 -3
  13. data/lib/fog/google/models/compute/images.rb +8 -2
  14. data/lib/fog/google/models/compute/resource_views.rb +2 -2
  15. data/lib/fog/google/models/compute/server.rb +37 -3
  16. data/lib/fog/google/models/compute/target_http_proxies.rb +5 -2
  17. data/lib/fog/google/models/compute/target_http_proxy.rb +1 -1
  18. data/lib/fog/google/models/compute/target_instance.rb +2 -2
  19. data/lib/fog/google/models/compute/target_instances.rb +21 -8
  20. data/lib/fog/google/models/compute/url_map.rb +1 -1
  21. data/lib/fog/google/models/compute/url_maps.rb +5 -2
  22. data/lib/fog/google/requests/compute/insert_target_instance.rb +1 -1
  23. data/lib/fog/google/requests/compute/list_aggregated_target_instances.rb +42 -0
  24. data/lib/fog/google/version.rb +1 -1
  25. data/test/helpers/integration_test_helper.rb +22 -0
  26. data/test/helpers/test_collection.rb +37 -0
  27. data/test/helpers/test_helper.rb +19 -0
  28. data/test/integration/compute/test_backend_services.rb +11 -0
  29. data/test/integration/compute/test_disk_types.rb +39 -0
  30. data/test/integration/compute/test_disks.rb +11 -0
  31. data/test/integration/compute/test_forwarding_rules.rb +11 -0
  32. data/test/integration/compute/test_global_forwarding_rules.rb +11 -0
  33. data/test/integration/compute/test_http_health_checks.rb +11 -0
  34. data/test/integration/compute/test_images.rb +11 -0
  35. data/test/integration/compute/test_regions.rb +33 -0
  36. data/test/integration/compute/test_servers.rb +28 -0
  37. data/test/integration/compute/test_target_http_proxies.rb +11 -0
  38. data/test/integration/compute/test_target_instances.rb +11 -0
  39. data/test/integration/compute/test_target_pools.rb +11 -0
  40. data/test/integration/compute/test_url_maps.rb +11 -0
  41. data/test/integration/factories/backend_services_factory.rb +19 -0
  42. data/test/integration/factories/collection_factory.rb +27 -0
  43. data/test/integration/factories/disks_factory.rb +13 -0
  44. data/test/integration/factories/forwarding_rules_factory.rb +21 -0
  45. data/test/integration/factories/global_forwarding_rules_factory.rb +19 -0
  46. data/test/integration/factories/http_health_checks_factory.rb +11 -0
  47. data/test/integration/factories/images_factory.rb +12 -0
  48. data/test/integration/factories/servers_factory.rb +21 -0
  49. data/test/integration/factories/target_http_proxies_factory.rb +19 -0
  50. data/test/integration/factories/target_instances_factory.rb +20 -0
  51. data/test/integration/factories/target_pools_factory.rb +24 -0
  52. data/test/integration/factories/url_maps_factory.rb +19 -0
  53. data/test/integration/test_authentication.rb +59 -0
  54. data/tests/helpers/collection_helper.rb +2 -0
  55. data/tests/helpers/model_helper.rb +2 -0
  56. metadata +61 -31
  57. data/.ruby-version +0 -1
  58. data/spec/minitest_helper.rb +0 -15
  59. data/tests/credentials_tests.rb +0 -73
  60. data/tests/models/compute/backend_service_tests.rb +0 -7
  61. data/tests/models/compute/backend_services_tests.rb +0 -8
  62. data/tests/models/compute/disk_tests.rb +0 -9
  63. data/tests/models/compute/disk_types_tests.rb +0 -22
  64. data/tests/models/compute/disks_tests.rb +0 -9
  65. data/tests/models/compute/forwarding_rule_tests.rb +0 -8
  66. data/tests/models/compute/forwarding_rules_tests.rb +0 -8
  67. data/tests/models/compute/global_forwarding_rule_tests.rb +0 -7
  68. data/tests/models/compute/global_forwarding_rules_tests.rb +0 -7
  69. data/tests/models/compute/http_health_check_tests.rb +0 -5
  70. data/tests/models/compute/http_health_checks_tests.rb +0 -5
  71. data/tests/models/compute/image_tests.rb +0 -6
  72. data/tests/models/compute/images_tests.rb +0 -6
  73. data/tests/models/compute/region_tests.rb +0 -10
  74. data/tests/models/compute/regions_tests.rb +0 -19
  75. data/tests/models/compute/server_tests.rb +0 -37
  76. data/tests/models/compute/servers_tests.rb +0 -14
  77. data/tests/models/compute/target_http_proxies_tests.rb +0 -7
  78. data/tests/models/compute/target_http_proxy_test.rb +0 -6
  79. data/tests/models/compute/target_instance_tests.rb +0 -7
  80. data/tests/models/compute/target_instances_tests.rb +0 -7
  81. data/tests/models/compute/target_pool_tests.rb +0 -12
  82. data/tests/models/compute/target_pools_tests.rb +0 -11
  83. data/tests/models/compute/url_map_tests.rb +0 -6
  84. data/tests/models/compute/url_maps_tests.rb +0 -7
@@ -0,0 +1,19 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/http_health_checks_factory"
3
+
4
+ class BackendServicesFactory < CollectionFactory
5
+ def initialize(example)
6
+ @http_health_checks = HttpHealthChecksFactory.new(example)
7
+ super(Fog::Compute[:google].backend_services, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @http_health_checks.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :health_checks => [@http_health_checks.create.self_link]}
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ class CollectionFactory
2
+ PREFIX = 'fog-test'
3
+
4
+ def initialize(subject, example)
5
+ @subject = subject
6
+ @example = example
7
+ @resource_counter = 0
8
+ end
9
+
10
+ def cleanup
11
+ resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
12
+ resources.each { |r| r.destroy }
13
+ resources.each { |r| Fog.wait_for { !@subject.all.map(&:identity).include? r.identity } }
14
+ end
15
+
16
+ def create
17
+ @subject.create(params)
18
+ end
19
+
20
+ def resource_name(base=@example, prefix=PREFIX)
21
+ index = @resource_counter += 1
22
+ # In prefix, convert - to _ to make sure that it doesn't get stripped by the \W strip below.
23
+ # Then, concatenate prefix, index, and base; strip all non-alphanumerics except _;
24
+ # convert _ to -; downcase; truncate to 62 characters; delete trailing -
25
+ ([prefix.gsub(/-/, '_'), index, base] * "_").gsub(/\W/, '').gsub(/_/, '-').downcase[0..61].chomp('-')
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ require "integration/factories/collection_factory"
2
+
3
+ class DisksFactory < CollectionFactory
4
+ def initialize(example)
5
+ super(Fog::Compute[:google].disks, example)
6
+ end
7
+
8
+ def params
9
+ {:name => resource_name,
10
+ :zone_name => TEST_ZONE,
11
+ :size_gb => TEST_SIZE_GB}
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/target_pools_factory"
3
+
4
+ class ForwardingRulesFactory < CollectionFactory
5
+ def initialize(example)
6
+ @target_pools = TargetPoolsFactory.new(example)
7
+ super(Fog::Compute[:google].forwarding_rules, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @target_pools.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :region => TEST_REGION,
18
+ :target => @target_pools.create.self_link}
19
+ end
20
+ end
21
+
@@ -0,0 +1,19 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/target_http_proxies_factory"
3
+
4
+ class GlobalForwardingRulesFactory < CollectionFactory
5
+ def initialize(example)
6
+ @targets = TargetHttpProxiesFactory.new(example)
7
+ super(Fog::Compute[:google].global_forwarding_rules, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @targets.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :target => @targets.create.self_link}
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ require "integration/factories/collection_factory"
2
+
3
+ class HttpHealthChecksFactory < CollectionFactory
4
+ def initialize(example)
5
+ super(Fog::Compute[:google].http_health_checks, example)
6
+ end
7
+
8
+ def params
9
+ {:name => resource_name}
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require "integration/factories/collection_factory"
2
+
3
+ class ImagesFactory < CollectionFactory
4
+ def initialize(example)
5
+ super(Fog::Compute[:google].images, example)
6
+ end
7
+
8
+ def params
9
+ params = {:name => resource_name,
10
+ :raw_disk => {:source => TEST_RAW_DISK_SOURCE}}
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/disks_factory"
3
+
4
+ class ServersFactory < CollectionFactory
5
+ def initialize(example)
6
+ @disks = DisksFactory.new(example)
7
+ super(Fog::Compute[:google].servers, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @disks.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :zone_name => TEST_ZONE,
18
+ :machine_type => TEST_MACHINE_TYPE,
19
+ :disks => [@disks.create]}
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/url_maps_factory"
3
+
4
+ class TargetHttpProxiesFactory < CollectionFactory
5
+ def initialize(example)
6
+ @url_maps = UrlMapsFactory.new(example)
7
+ super(Fog::Compute[:google].target_http_proxies, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @url_maps.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :url_map => @url_maps.create.self_link}
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/servers_factory"
3
+
4
+ class TargetInstancesFactory < CollectionFactory
5
+ def initialize(example)
6
+ @servers = ServersFactory.new(example)
7
+ super(Fog::Compute[:google].target_instances, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @servers.cleanup
13
+ end
14
+
15
+ def params
16
+ {:name => resource_name,
17
+ :zone => TEST_ZONE,
18
+ :instance => @servers.create}
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/servers_factory"
3
+ require "integration/factories/http_health_checks_factory"
4
+
5
+ class TargetPoolsFactory < CollectionFactory
6
+ def initialize(example)
7
+ @http_health_checks = HttpHealthChecksFactory.new(example)
8
+ @servers = ServersFactory.new(example)
9
+ super(Fog::Compute[:google].target_pools, example)
10
+ end
11
+
12
+ def cleanup
13
+ super
14
+ @servers.cleanup
15
+ @http_health_checks.cleanup
16
+ end
17
+
18
+ def params
19
+ params = {:name => resource_name,
20
+ :region => TEST_REGION,
21
+ :instances => [@servers.create.self_link],
22
+ :healthChecks => [@http_health_checks.create.self_link]}
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ require "integration/factories/collection_factory"
2
+ require "integration/factories/backend_services_factory"
3
+
4
+ class UrlMapsFactory < CollectionFactory
5
+ def initialize(example)
6
+ @backend_services = BackendServicesFactory.new(example)
7
+ super(Fog::Compute[:google].url_maps, example)
8
+ end
9
+
10
+ def cleanup
11
+ super
12
+ @backend_services.cleanup
13
+ end
14
+
15
+ def params
16
+ params = {:name => resource_name,
17
+ :default_service => @backend_services.create.self_link}
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ require 'helpers/integration_test_helper'
2
+
3
+ # TODO this is a port over from legacy tests. It shouldn't be scoped under Google, but under Google::Shared.
4
+ class TestAuthentication < FogIntegrationTest
5
+ def setup
6
+ @google_key_location = Fog.credentials[:google_key_location]
7
+ @google_key_string = File.open(File.expand_path(@google_key_location), 'rb') { |io| io.read }
8
+ @google_json_key_location = Fog.credentials[:google_json_key_location]
9
+ @google_json_key_string = File.open(File.expand_path(@google_json_key_location), 'rb') { |io| io.read }
10
+ end
11
+
12
+ def test_authenticates_with_p12_key_location
13
+ c = Fog::Compute::Google.new(:google_key_location => @google_key_location,
14
+ :google_key_string => nil,
15
+ :google_json_key_location => nil,
16
+ :google_json_key_string => nil)
17
+ assert_kind_of(Fog::Compute::Google::Real, c)
18
+ end
19
+
20
+ def test_authenticates_with_p12_key_string
21
+ c = Fog::Compute::Google.new(:google_key_location => nil,
22
+ :google_key_string => @google_key_string,
23
+ :google_json_key_location => nil,
24
+ :google_json_key_string => nil)
25
+ assert_kind_of(Fog::Compute::Google::Real, c)
26
+ end
27
+
28
+ def test_authenticates_with_json_key_location
29
+ c = Fog::Compute::Google.new(:google_key_location => nil,
30
+ :google_key_string => nil,
31
+ :google_json_key_location => @google_json_key_location,
32
+ :google_json_key_string => nil)
33
+ assert_kind_of(Fog::Compute::Google::Real, c)
34
+ end
35
+
36
+ def test_authenticates_with_json_key_string
37
+ c = Fog::Compute::Google.new(:google_key_location => nil,
38
+ :google_key_string => nil,
39
+ :google_json_key_location => nil,
40
+ :google_json_key_string => @google_json_key_string)
41
+ assert_kind_of(Fog::Compute::Google::Real, c)
42
+ end
43
+
44
+ def test_raises_argument_error_when_google_project_is_missing
45
+ assert_raises(ArgumentError) { Fog::Compute::Google.new(:google_project => nil) }
46
+ end
47
+
48
+ def test_raises_argument_error_when_google_client_email_is_missing
49
+ assert_raises(ArgumentError) { Fog::Compute::Google.new(:google_client_email => nil,
50
+ :google_json_key_location => nil) } # JSON key overrides google_client_email
51
+ end
52
+
53
+ def test_raises_argument_error_when_google_keys_are_given
54
+ assert_raises(ArgumentError) { Fog::Compute::Google.new(:google_key_location => nil,
55
+ :google_key_string => nil,
56
+ :google_json_key_location => nil,
57
+ :google_json_key_string => nil) }
58
+ end
59
+ end
@@ -1,3 +1,5 @@
1
+ # TODO REMOVE this testing functionality is now covered in `spec/helpers/model_helper.rb`
2
+
1
3
  def collection_tests(collection, params = {}, mocks_implemented = true)
2
4
  tests('success') do
3
5
 
@@ -1,3 +1,5 @@
1
+ # TODO REMOVE this testing functionality is now covered in `spec/helpers/model_helper.rb`
2
+
1
3
  def model_tests(collection, params = {}, mocks_implemented = true)
2
4
  tests('success') do
3
5
 
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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Welch
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-22 00:00:00.000000000 Z
13
+ date: 2015-06-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog-core
@@ -200,7 +200,6 @@ files:
200
200
  - ".gitignore"
201
201
  - ".rubocop.yml"
202
202
  - ".ruby-gemset"
203
- - ".ruby-version"
204
203
  - ".travis.yml"
205
204
  - CONTRIBUTING.md
206
205
  - CONTRIBUTORS.md
@@ -410,6 +409,7 @@ files:
410
409
  - lib/fog/google/requests/compute/list_aggregated_disks.rb
411
410
  - lib/fog/google/requests/compute/list_aggregated_machine_types.rb
412
411
  - lib/fog/google/requests/compute/list_aggregated_servers.rb
412
+ - lib/fog/google/requests/compute/list_aggregated_target_instances.rb
413
413
  - lib/fog/google/requests/compute/list_backend_services.rb
414
414
  - lib/fog/google/requests/compute/list_disk_types.rb
415
415
  - lib/fog/google/requests/compute/list_disks.rb
@@ -507,8 +507,35 @@ files:
507
507
  - lib/fog/google/sql.rb
508
508
  - lib/fog/google/storage.rb
509
509
  - lib/fog/google/version.rb
510
- - spec/minitest_helper.rb
511
- - tests/credentials_tests.rb
510
+ - test/helpers/integration_test_helper.rb
511
+ - test/helpers/test_collection.rb
512
+ - test/helpers/test_helper.rb
513
+ - test/integration/compute/test_backend_services.rb
514
+ - test/integration/compute/test_disk_types.rb
515
+ - test/integration/compute/test_disks.rb
516
+ - test/integration/compute/test_forwarding_rules.rb
517
+ - test/integration/compute/test_global_forwarding_rules.rb
518
+ - test/integration/compute/test_http_health_checks.rb
519
+ - test/integration/compute/test_images.rb
520
+ - test/integration/compute/test_regions.rb
521
+ - test/integration/compute/test_servers.rb
522
+ - test/integration/compute/test_target_http_proxies.rb
523
+ - test/integration/compute/test_target_instances.rb
524
+ - test/integration/compute/test_target_pools.rb
525
+ - test/integration/compute/test_url_maps.rb
526
+ - test/integration/factories/backend_services_factory.rb
527
+ - test/integration/factories/collection_factory.rb
528
+ - test/integration/factories/disks_factory.rb
529
+ - test/integration/factories/forwarding_rules_factory.rb
530
+ - test/integration/factories/global_forwarding_rules_factory.rb
531
+ - test/integration/factories/http_health_checks_factory.rb
532
+ - test/integration/factories/images_factory.rb
533
+ - test/integration/factories/servers_factory.rb
534
+ - test/integration/factories/target_http_proxies_factory.rb
535
+ - test/integration/factories/target_instances_factory.rb
536
+ - test/integration/factories/target_pools_factory.rb
537
+ - test/integration/factories/url_maps_factory.rb
538
+ - test/integration/test_authentication.rb
512
539
  - tests/helper.rb
513
540
  - tests/helpers/collection_helper.rb
514
541
  - tests/helpers/compute/flavors_helper.rb
@@ -522,31 +549,6 @@ files:
522
549
  - tests/helpers/schema_validator_tests.rb
523
550
  - tests/helpers/succeeds_helper.rb
524
551
  - tests/lorem.txt
525
- - tests/models/compute/backend_service_tests.rb
526
- - tests/models/compute/backend_services_tests.rb
527
- - tests/models/compute/disk_tests.rb
528
- - tests/models/compute/disk_types_tests.rb
529
- - tests/models/compute/disks_tests.rb
530
- - tests/models/compute/forwarding_rule_tests.rb
531
- - tests/models/compute/forwarding_rules_tests.rb
532
- - tests/models/compute/global_forwarding_rule_tests.rb
533
- - tests/models/compute/global_forwarding_rules_tests.rb
534
- - tests/models/compute/http_health_check_tests.rb
535
- - tests/models/compute/http_health_checks_tests.rb
536
- - tests/models/compute/image_tests.rb
537
- - tests/models/compute/images_tests.rb
538
- - tests/models/compute/region_tests.rb
539
- - tests/models/compute/regions_tests.rb
540
- - tests/models/compute/server_tests.rb
541
- - tests/models/compute/servers_tests.rb
542
- - tests/models/compute/target_http_proxies_tests.rb
543
- - tests/models/compute/target_http_proxy_test.rb
544
- - tests/models/compute/target_instance_tests.rb
545
- - tests/models/compute/target_instances_tests.rb
546
- - tests/models/compute/target_pool_tests.rb
547
- - tests/models/compute/target_pools_tests.rb
548
- - tests/models/compute/url_map_tests.rb
549
- - tests/models/compute/url_maps_tests.rb
550
552
  - tests/models/dns/change_tests.rb
551
553
  - tests/models/dns/changes_tests.rb
552
554
  - tests/models/dns/projects_tests.rb
@@ -621,5 +623,33 @@ signing_key:
621
623
  specification_version: 4
622
624
  summary: Module for the 'fog' gem to support Google.
623
625
  test_files:
624
- - spec/minitest_helper.rb
626
+ - test/helpers/integration_test_helper.rb
627
+ - test/helpers/test_collection.rb
628
+ - test/helpers/test_helper.rb
629
+ - test/integration/compute/test_backend_services.rb
630
+ - test/integration/compute/test_disk_types.rb
631
+ - test/integration/compute/test_disks.rb
632
+ - test/integration/compute/test_forwarding_rules.rb
633
+ - test/integration/compute/test_global_forwarding_rules.rb
634
+ - test/integration/compute/test_http_health_checks.rb
635
+ - test/integration/compute/test_images.rb
636
+ - test/integration/compute/test_regions.rb
637
+ - test/integration/compute/test_servers.rb
638
+ - test/integration/compute/test_target_http_proxies.rb
639
+ - test/integration/compute/test_target_instances.rb
640
+ - test/integration/compute/test_target_pools.rb
641
+ - test/integration/compute/test_url_maps.rb
642
+ - test/integration/factories/backend_services_factory.rb
643
+ - test/integration/factories/collection_factory.rb
644
+ - test/integration/factories/disks_factory.rb
645
+ - test/integration/factories/forwarding_rules_factory.rb
646
+ - test/integration/factories/global_forwarding_rules_factory.rb
647
+ - test/integration/factories/http_health_checks_factory.rb
648
+ - test/integration/factories/images_factory.rb
649
+ - test/integration/factories/servers_factory.rb
650
+ - test/integration/factories/target_http_proxies_factory.rb
651
+ - test/integration/factories/target_instances_factory.rb
652
+ - test/integration/factories/target_pools_factory.rb
653
+ - test/integration/factories/url_maps_factory.rb
654
+ - test/integration/test_authentication.rb
625
655
  has_rdoc: