fog-google 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/integration-compute-core.yml +2 -2
- data/.github/workflows/integration-compute-instance_groups.yml +2 -2
- data/.github/workflows/integration-compute-loadbalancing.yml +2 -2
- data/.github/workflows/integration-compute-networking.yml +2 -2
- data/.github/workflows/integration-monitoring.yml +2 -2
- data/.github/workflows/integration-pubsub.yml +2 -2
- data/.github/workflows/integration-sql.yml +2 -2
- data/.github/workflows/integration-storage.yml +2 -2
- data/.github/workflows/unit.yml +2 -2
- data/CHANGELOG.md +46 -27
- data/SECURITY.md +3 -14
- data/fog-google.gemspec +2 -3
- data/lib/fog/google/compute/models/server.rb +1 -1
- data/lib/fog/google/storage/storage_json/real.rb +4 -2
- data/lib/fog/google/storage/storage_json/utils.rb +4 -2
- data/lib/fog/google/storage/storage_xml/real.rb +4 -2
- data/lib/fog/google/storage/storage_xml/requests/get_bucket.rb +1 -1
- data/lib/fog/google/storage/storage_xml/utils.rb +4 -2
- data/lib/fog/google/version.rb +1 -1
- metadata +5 -198
- data/.github/workflows/stale.yml +0 -23
- data/test/helpers/client_helper.rb +0 -63
- data/test/helpers/integration_test_helper.rb +0 -108
- data/test/helpers/test_collection.rb +0 -60
- data/test/helpers/test_helper.rb +0 -28
- data/test/integration/compute/core_compute/test_client_options.rb +0 -12
- data/test/integration/compute/core_compute/test_coverage.rb +0 -6
- data/test/integration/compute/core_compute/test_disk_types.rb +0 -43
- data/test/integration/compute/core_compute/test_disks.rb +0 -53
- data/test/integration/compute/core_compute/test_images.rb +0 -32
- data/test/integration/compute/core_compute/test_machine_types.rb +0 -55
- data/test/integration/compute/core_compute/test_operations.rb +0 -45
- data/test/integration/compute/core_compute/test_projects.rb +0 -19
- data/test/integration/compute/core_compute/test_regions.rb +0 -33
- data/test/integration/compute/core_compute/test_servers.rb +0 -235
- data/test/integration/compute/core_compute/test_snapshots.rb +0 -21
- data/test/integration/compute/core_compute/test_zones.rb +0 -35
- data/test/integration/compute/core_networking/test_addresses.rb +0 -107
- data/test/integration/compute/core_networking/test_coverage.rb +0 -6
- data/test/integration/compute/core_networking/test_firewalls.rb +0 -11
- data/test/integration/compute/core_networking/test_networks.rb +0 -30
- data/test/integration/compute/core_networking/test_routes.rb +0 -26
- data/test/integration/compute/core_networking/test_subnetworks.rb +0 -11
- data/test/integration/compute/instance_groups/test_coverage.rb +0 -6
- data/test/integration/compute/instance_groups/test_instance_group_managers.rb +0 -11
- data/test/integration/compute/instance_groups/test_instance_groups.rb +0 -11
- data/test/integration/compute/instance_groups/test_instance_templates.rb +0 -11
- data/test/integration/compute/loadbalancing/test_backend_services.rb +0 -11
- data/test/integration/compute/loadbalancing/test_coverage.rb +0 -6
- data/test/integration/compute/loadbalancing/test_forwarding_rules.rb +0 -11
- data/test/integration/compute/loadbalancing/test_global_addresses.rb +0 -11
- data/test/integration/compute/loadbalancing/test_global_forwarding_rules.rb +0 -11
- data/test/integration/compute/loadbalancing/test_http_health_checks.rb +0 -11
- data/test/integration/compute/loadbalancing/test_ssl_certificates.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_http_proxies.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_https_proxies.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_instances.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_pools.rb +0 -55
- data/test/integration/compute/loadbalancing/test_url_maps.rb +0 -11
- data/test/integration/factories/addresses_factory.rb +0 -20
- data/test/integration/factories/backend_services_factory.rb +0 -19
- data/test/integration/factories/collection_factory.rb +0 -52
- data/test/integration/factories/disks_factory.rb +0 -22
- data/test/integration/factories/firewalls_factory.rb +0 -13
- data/test/integration/factories/forwarding_rules_factory.rb +0 -25
- data/test/integration/factories/global_addresses_factory.rb +0 -15
- data/test/integration/factories/global_forwarding_rules_factory.rb +0 -20
- data/test/integration/factories/http_health_checks_factory.rb +0 -11
- data/test/integration/factories/images_factory.rb +0 -16
- data/test/integration/factories/instance_group_manager_factory.rb +0 -30
- data/test/integration/factories/instance_groups_factory.rb +0 -20
- data/test/integration/factories/instance_template_factory.rb +0 -24
- data/test/integration/factories/networks_factory.rb +0 -14
- data/test/integration/factories/servers_factory.rb +0 -30
- data/test/integration/factories/sql_certs_factory.rb +0 -20
- data/test/integration/factories/sql_instances_factory.rb +0 -19
- data/test/integration/factories/sql_users_factory.rb +0 -23
- data/test/integration/factories/ssl_certificates_factory.rb +0 -13
- data/test/integration/factories/subnetworks_factory.rb +0 -26
- data/test/integration/factories/target_http_proxies_factory.rb +0 -19
- data/test/integration/factories/target_https_proxies_factory.rb +0 -26
- data/test/integration/factories/target_instances_factory.rb +0 -24
- data/test/integration/factories/target_pools_factory.rb +0 -28
- data/test/integration/factories/url_maps_factory.rb +0 -19
- data/test/integration/monitoring/test_coverage.rb +0 -6
- data/test/integration/monitoring/test_metric_descriptors.rb +0 -131
- data/test/integration/monitoring/test_monitored_resource_descriptors.rb +0 -37
- data/test/integration/monitoring/test_timeseries.rb +0 -253
- data/test/integration/pubsub/pubsub_shared.rb +0 -75
- data/test/integration/pubsub/test_coverage.rb +0 -6
- data/test/integration/pubsub/test_pubsub_models.rb +0 -135
- data/test/integration/pubsub/test_pubsub_requests.rb +0 -105
- data/test/integration/sql/test_certs.rb +0 -50
- data/test/integration/sql/test_common_flags.rb +0 -31
- data/test/integration/sql/test_common_tiers.rb +0 -26
- data/test/integration/sql/test_coverage.rb +0 -6
- data/test/integration/sql/test_instances.rb +0 -101
- data/test/integration/sql/test_users.rb +0 -37
- data/test/integration/storage/storage_shared.rb +0 -101
- data/test/integration/storage/test_buckets.rb +0 -112
- data/test/integration/storage/test_coverage.rb +0 -6
- data/test/integration/storage/test_directories.rb +0 -67
- data/test/integration/storage/test_files.rb +0 -168
- data/test/integration/storage/test_objects.rb +0 -226
- data/test/integration/test_authentication.rb +0 -38
- data/test/unit/compute/test_common_collections.rb +0 -42
- data/test/unit/compute/test_common_models.rb +0 -35
- data/test/unit/compute/test_disk.rb +0 -26
- data/test/unit/compute/test_server.rb +0 -29
- data/test/unit/dns/test_common_collections.rb +0 -43
- data/test/unit/monitoring/test_comon_collections.rb +0 -44
- data/test/unit/pubsub/test_common_collections.rb +0 -35
- data/test/unit/sql/test_common_collections.rb +0 -46
- data/test/unit/storage/test_common_json_collections.rb +0 -38
- data/test/unit/storage/test_common_xml_collections.rb +0 -50
- data/test/unit/storage/test_json_requests.rb +0 -60
- data/test/unit/storage/test_xml_requests.rb +0 -60
@@ -1,112 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/storage/storage_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
require "tempfile"
|
6
|
-
|
7
|
-
class TestStorageRequests < StorageShared
|
8
|
-
def test_put_bucket
|
9
|
-
bucket_name = new_bucket_name
|
10
|
-
bucket = @client.put_bucket(bucket_name)
|
11
|
-
|
12
|
-
assert_equal(bucket.name, bucket_name)
|
13
|
-
end
|
14
|
-
|
15
|
-
# We cannot test the state of the ACL as there are two cases to consider
|
16
|
-
# * The authenticated service account has Owner permisions, which allows
|
17
|
-
# it to read the ACLs after the predefined ACL is applied.
|
18
|
-
# * The authenticated service account does not have Owner permissions,
|
19
|
-
# then, we cannot read the ACLs after the predefined ACL is applied.
|
20
|
-
#
|
21
|
-
# As we cannot control the service account used for testing, we'll
|
22
|
-
# just ensure that a valid operation succeeds and an invalid operation fails.
|
23
|
-
def test_put_bucket_predefined_acl
|
24
|
-
@client.put_bucket(new_bucket_name, :predefined_acl => "publicRead")
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_put_bucket_invalid_predefined_acl
|
28
|
-
assert_raises(Google::Apis::ClientError) do
|
29
|
-
@client.put_bucket(new_bucket_name, :predefined_acl => "invalidAcl")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_get_bucket
|
34
|
-
bucket = @client.get_bucket(some_bucket_name)
|
35
|
-
assert_equal(bucket.name, some_bucket_name)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_delete_bucket
|
39
|
-
# Create a new bucket to delete it
|
40
|
-
bucket_to_delete = new_bucket_name
|
41
|
-
@client.put_bucket(bucket_to_delete)
|
42
|
-
|
43
|
-
@client.delete_bucket(bucket_to_delete)
|
44
|
-
|
45
|
-
assert_raises(Google::Apis::ClientError) do
|
46
|
-
@client.get_bucket(bucket_to_delete)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_list_buckets
|
51
|
-
# Create a new bucket to ensure at least one exists to find
|
52
|
-
bucket_name = new_bucket_name
|
53
|
-
@client.put_bucket(bucket_name)
|
54
|
-
|
55
|
-
result = @client.list_buckets
|
56
|
-
if result.items.nil?
|
57
|
-
raise StandardError.new("no buckets found")
|
58
|
-
end
|
59
|
-
|
60
|
-
contained = result.items.any? { |bucket| bucket.name == bucket_name }
|
61
|
-
assert_equal(true, contained, "expected bucket not present")
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_put_bucket_acl
|
65
|
-
bucket_name = new_bucket_name
|
66
|
-
@client.put_bucket(bucket_name)
|
67
|
-
|
68
|
-
acl = {
|
69
|
-
:entity => "allUsers",
|
70
|
-
:role => "READER"
|
71
|
-
}
|
72
|
-
@client.put_bucket_acl(bucket_name, acl)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_list_bucket_acl
|
76
|
-
bucket_name = new_bucket_name
|
77
|
-
@client.put_bucket(bucket_name)
|
78
|
-
|
79
|
-
acl = {
|
80
|
-
:entity => "allUsers",
|
81
|
-
:role => "READER"
|
82
|
-
}
|
83
|
-
@client.put_bucket_acl(bucket_name, acl)
|
84
|
-
|
85
|
-
result = @client.list_bucket_acl(bucket_name)
|
86
|
-
if result.items.nil?
|
87
|
-
raise StandardError.new("no bucket access controls found")
|
88
|
-
end
|
89
|
-
|
90
|
-
contained = result.items.any? do |control|
|
91
|
-
control.entity == acl[:entity] && control.role == acl[:role]
|
92
|
-
end
|
93
|
-
assert_equal(true, contained, "expected bucket access control not present")
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_get_bucket_acl
|
97
|
-
bucket_name = new_bucket_name
|
98
|
-
@client.put_bucket(bucket_name)
|
99
|
-
|
100
|
-
acl = {
|
101
|
-
:entity => "allUsers",
|
102
|
-
:role => "READER"
|
103
|
-
}
|
104
|
-
@client.put_bucket_acl(bucket_name, acl)
|
105
|
-
result = @client.get_bucket_acl(bucket_name, "allUsers")
|
106
|
-
if result.nil?
|
107
|
-
raise StandardError.new("no bucket access control found")
|
108
|
-
end
|
109
|
-
|
110
|
-
assert_equal(result.role, acl[:role], "incorrect bucket access control role")
|
111
|
-
end
|
112
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
# This is a simple coverage helper that helps differentiate
|
4
|
-
# the tests when run in parallel so the final coverage report
|
5
|
-
# can be properly combined together from multiple runners
|
6
|
-
SimpleCov.command_name "test:storage" if ENV["COVERAGE"]
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/storage/storage_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
require "tempfile"
|
6
|
-
|
7
|
-
class TestStorageRequests < StorageShared
|
8
|
-
def test_directories_put
|
9
|
-
dir_name = new_bucket_name
|
10
|
-
directory = @client.directories.create(:key => dir_name)
|
11
|
-
assert_equal(directory.key, dir_name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_directories_put_predefined_acl
|
15
|
-
@client.directories.create(
|
16
|
-
:key => new_bucket_name,
|
17
|
-
:predefined_acl => "publicRead"
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_directories_put_invalid_predefined_acl
|
22
|
-
assert_raises(Google::Apis::ClientError) do
|
23
|
-
@client.directories.create(
|
24
|
-
:key => new_bucket_name,
|
25
|
-
:predefined_acl => "invalidAcl"
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_directories_get
|
31
|
-
directory = @client.directories.get(some_bucket_name)
|
32
|
-
assert_equal(directory.key, some_bucket_name)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_directory_files
|
36
|
-
file = @client.directories.get(some_bucket_name).files.get(some_object_name)
|
37
|
-
assert_equal(some_object_name, file.key)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_directory_public_url
|
41
|
-
url = @client.directories.get(some_bucket_name).public_url
|
42
|
-
assert_match(/storage.googleapis.com/, url)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_directories_destroy
|
46
|
-
dir_name = new_bucket_name
|
47
|
-
@client.directories.create(:key => dir_name)
|
48
|
-
|
49
|
-
@client.directories.destroy(dir_name)
|
50
|
-
|
51
|
-
assert_nil(@client.directories.get(dir_name))
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_directories_all
|
55
|
-
dir_name = new_bucket_name
|
56
|
-
@client.directories.create(:key => dir_name)
|
57
|
-
|
58
|
-
result = @client.directories.all
|
59
|
-
if result.nil?
|
60
|
-
raise StandardError.new("no directories found")
|
61
|
-
end
|
62
|
-
|
63
|
-
unless result.any? { |directory| directory.key == dir_name }
|
64
|
-
raise StandardError.new("failed to find expected directory")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/storage/storage_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
require "tempfile"
|
6
|
-
|
7
|
-
class TestStorageRequests < StorageShared
|
8
|
-
def test_files_create_file
|
9
|
-
file_name = new_object_name
|
10
|
-
@client.directories.get(some_bucket_name).files.create(
|
11
|
-
:key => file_name,
|
12
|
-
:body => some_temp_file
|
13
|
-
)
|
14
|
-
|
15
|
-
object = @client.get_object(some_bucket_name, file_name)
|
16
|
-
assert_equal(object[:body], temp_file_content)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_files_create_string
|
20
|
-
expected_body = "A file body"
|
21
|
-
file_name = new_object_name
|
22
|
-
@client.directories.get(some_bucket_name).files.create(
|
23
|
-
:key => file_name,
|
24
|
-
:body => expected_body
|
25
|
-
)
|
26
|
-
|
27
|
-
object = @client.get_object(some_bucket_name, file_name)
|
28
|
-
assert_equal(object[:body], expected_body)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_files_create_predefined_acl
|
32
|
-
@client.directories.get(some_bucket_name).files.create(
|
33
|
-
:key => new_object_name,
|
34
|
-
:body => some_temp_file,
|
35
|
-
:predefined_acl => "publicRead"
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_files_create_invalid_predefined_acl
|
40
|
-
assert_raises(ArgumentError) do
|
41
|
-
@client.directories.get(some_bucket_name).files.create(
|
42
|
-
:key => new_object_name,
|
43
|
-
:body => some_temp_file,
|
44
|
-
:predefined_acl => "invalidAcl"
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_files_get
|
50
|
-
content = @client.directories.get(some_bucket_name).files.get(some_object_name)
|
51
|
-
assert_equal(content.body, temp_file_content)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_files_set_body_string
|
55
|
-
file_name = new_object_name
|
56
|
-
directory = @client.directories.get(some_bucket_name)
|
57
|
-
file = directory.files.create(
|
58
|
-
:key => file_name,
|
59
|
-
:body => temp_file_content
|
60
|
-
)
|
61
|
-
|
62
|
-
assert_equal(file.body, temp_file_content)
|
63
|
-
|
64
|
-
new_body = "Changed file body"
|
65
|
-
file.body = new_body
|
66
|
-
file.save
|
67
|
-
|
68
|
-
updated_file = directory.files.get(file_name)
|
69
|
-
assert_equal(updated_file.body, new_body)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_files_set_body_file
|
73
|
-
file_name = new_object_name
|
74
|
-
directory = @client.directories.get(some_bucket_name)
|
75
|
-
file = directory.files.create(
|
76
|
-
:key => file_name,
|
77
|
-
:body => some_temp_file
|
78
|
-
)
|
79
|
-
|
80
|
-
new_body = "Changed file body"
|
81
|
-
file.body = new_body
|
82
|
-
file.save
|
83
|
-
|
84
|
-
updated_file = directory.files.get(file_name)
|
85
|
-
assert_equal(updated_file.body, new_body)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_files_metadata
|
89
|
-
content = @client.directories.get(some_bucket_name).files.metadata(some_object_name)
|
90
|
-
assert_equal(content.content_length, temp_file_content.length)
|
91
|
-
assert_equal(content.key, some_object_name)
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_files_destroy
|
95
|
-
file_name = new_object_name
|
96
|
-
@client.directories.get(some_bucket_name).files.create(
|
97
|
-
:key => file_name,
|
98
|
-
:body => some_temp_file
|
99
|
-
)
|
100
|
-
|
101
|
-
@client.directories.get(some_bucket_name).files.destroy(file_name)
|
102
|
-
|
103
|
-
assert_nil(@client.directories.get(some_bucket_name).files.get(file_name))
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_files_all
|
107
|
-
file_name = new_object_name
|
108
|
-
@client.directories.get(some_bucket_name).files.create(
|
109
|
-
:key => file_name,
|
110
|
-
:body => some_temp_file
|
111
|
-
)
|
112
|
-
|
113
|
-
result = @client.directories.get(some_bucket_name).files.all
|
114
|
-
if result.nil?
|
115
|
-
raise StandardError.new("no files found")
|
116
|
-
end
|
117
|
-
|
118
|
-
unless result.any? { |file| file.key == file_name }
|
119
|
-
raise StandardError.new("failed to find expected file")
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_files_each
|
124
|
-
file_name = new_object_name
|
125
|
-
@client.directories.get(some_bucket_name).files.create(
|
126
|
-
:key => file_name,
|
127
|
-
:body => some_temp_file
|
128
|
-
)
|
129
|
-
|
130
|
-
found_file = false
|
131
|
-
@client.directories.get(some_bucket_name).files.each do |file|
|
132
|
-
if file.key == file_name
|
133
|
-
found_file = true
|
134
|
-
end
|
135
|
-
end
|
136
|
-
assert_equal(true, found_file, "failed to find expected file while iterating")
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_files_copy
|
140
|
-
target_object_name = new_object_name
|
141
|
-
@client.directories.get(some_bucket_name).files.get(some_object_name).copy(some_bucket_name,
|
142
|
-
target_object_name)
|
143
|
-
|
144
|
-
content = @client.directories.get(some_bucket_name).files.get(target_object_name)
|
145
|
-
assert_equal(content.body, temp_file_content)
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_files_public_url
|
149
|
-
url = @client.directories.get(some_bucket_name).files.get(some_object_name).public_url
|
150
|
-
assert_match(/storage.googleapis.com/, url)
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_files_get_https_url
|
154
|
-
directory = @client.directories.get(some_bucket_name)
|
155
|
-
https_url = directory.files.get_https_url("fog-testfile", (Time.now + 60).to_i)
|
156
|
-
assert_match(/https/, https_url)
|
157
|
-
assert_match(/#{bucket_prefix}/, https_url)
|
158
|
-
assert_match(/fog-testfile/, https_url)
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_files_get_https_url_whitespace
|
162
|
-
directory = @client.directories.get(some_bucket_name)
|
163
|
-
https_url = directory.files.get_https_url("fog -testfile", (Time.now + 60).to_i)
|
164
|
-
assert_match(/https/, https_url)
|
165
|
-
assert_match(/#{bucket_prefix}/, https_url)
|
166
|
-
assert_match(/fog\%20-testfile/, https_url)
|
167
|
-
end
|
168
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/storage/storage_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
require "tempfile"
|
6
|
-
require "net/http"
|
7
|
-
require "ostruct"
|
8
|
-
|
9
|
-
class TestStorageRequests < StorageShared
|
10
|
-
def test_put_object_string
|
11
|
-
object_name = new_object_name
|
12
|
-
@client.put_object(some_bucket_name, object_name, some_temp_file)
|
13
|
-
|
14
|
-
object = @client.get_object(some_bucket_name, object_name)
|
15
|
-
|
16
|
-
assert_equal(object_name, object[:name])
|
17
|
-
assert_equal(temp_file_content, object[:body])
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_put_object_nil
|
21
|
-
assert_raises(ArgumentError) do
|
22
|
-
@client.put_object(some_bucket_name, new_object_name, nil)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_put_object_file
|
27
|
-
object_name = new_object_name
|
28
|
-
expected_body = "A file body"
|
29
|
-
@client.put_object(some_bucket_name, object_name, expected_body)
|
30
|
-
|
31
|
-
object = @client.get_object(some_bucket_name, object_name)
|
32
|
-
assert_equal(object_name, object[:name])
|
33
|
-
assert_equal(expected_body, object[:body])
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_put_object_paperclip
|
37
|
-
object_name = new_object_name
|
38
|
-
paperclip_file = OpenStruct.new(:path => some_temp_file(binary_file_content),
|
39
|
-
:content_type => "image/png")
|
40
|
-
@client.put_object(some_bucket_name, object_name, paperclip_file, :content_type => "image/png")
|
41
|
-
|
42
|
-
object = @client.get_object(some_bucket_name, object_name)
|
43
|
-
|
44
|
-
assert_equal(object_name, object[:name])
|
45
|
-
assert_equal(Encoding::ASCII_8BIT, object[:body].encoding)
|
46
|
-
assert_equal(binary_file_content, object[:body])
|
47
|
-
assert_equal("image/png", object[:content_type])
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_put_object_contradictory_content_type
|
51
|
-
object_name = new_object_name
|
52
|
-
file = OpenStruct.new(:path => some_temp_file,
|
53
|
-
:content_type => "text/plain")
|
54
|
-
@client.put_object(some_bucket_name, object_name, file, :content_type => "image/png")
|
55
|
-
|
56
|
-
object = @client.get_object(some_bucket_name, object_name)
|
57
|
-
|
58
|
-
assert_equal(object_name, object[:name])
|
59
|
-
assert_equal("image/png", object[:content_type])
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_put_object_predefined_acl
|
63
|
-
@client.put_object(some_bucket_name, new_object_name, some_temp_file,
|
64
|
-
:predefined_acl => "publicRead")
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_put_object_invalid_predefined_acl
|
68
|
-
assert_raises(Google::Apis::ClientError) do
|
69
|
-
@client.put_object(some_bucket_name, new_object_name, some_temp_file,
|
70
|
-
:predefined_acl => "invalidAcl")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_get_object
|
75
|
-
object = @client.get_object(some_bucket_name, some_object_name)
|
76
|
-
assert_equal(temp_file_content, object[:body])
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_delete_object
|
80
|
-
object_name = new_object_name
|
81
|
-
@client.put_object(some_bucket_name, object_name, some_temp_file)
|
82
|
-
@client.delete_object(some_bucket_name, object_name)
|
83
|
-
|
84
|
-
assert_raises(Google::Apis::ClientError) do
|
85
|
-
@client.get_object(some_bucket_name, object_name)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_object_metadata
|
90
|
-
object = @client.get_object_metadata(some_bucket_name, some_object_name)
|
91
|
-
assert_equal(temp_file_content.length, object.size)
|
92
|
-
assert_equal(some_bucket_name, object.bucket)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_copy_object
|
96
|
-
target_object_name = new_object_name
|
97
|
-
|
98
|
-
@client.copy_object(some_bucket_name, some_object_name,
|
99
|
-
some_bucket_name, target_object_name)
|
100
|
-
|
101
|
-
object = @client.get_object(some_bucket_name, target_object_name)
|
102
|
-
|
103
|
-
assert_equal(temp_file_content, object[:body])
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_copy_object_predefined_acl
|
107
|
-
target_object_name = new_object_name
|
108
|
-
|
109
|
-
res = @client.copy_object(some_bucket_name, some_object_name,
|
110
|
-
some_bucket_name, target_object_name, destination_predefined_acl: "publicRead")
|
111
|
-
|
112
|
-
result = @client.get_object(some_bucket_name, target_object_name)
|
113
|
-
|
114
|
-
response = Net::HTTP.get_response(URI(result[:self_link]))
|
115
|
-
|
116
|
-
assert_kind_of(Net::HTTPOK, response)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_copy_object_with_request_options
|
120
|
-
assert_raises(Google::Apis::AuthorizationError) do
|
121
|
-
target_object_name = new_object_name
|
122
|
-
|
123
|
-
@client.copy_object(some_bucket_name, some_object_name,
|
124
|
-
some_bucket_name, target_object_name, authorization: false)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_copy_object_with_object_property
|
129
|
-
target_object_name = new_object_name
|
130
|
-
|
131
|
-
@client.copy_object(some_bucket_name, some_object_name,
|
132
|
-
some_bucket_name, target_object_name, content_type: 'text/plain')
|
133
|
-
|
134
|
-
object = @client.get_object(some_bucket_name, target_object_name)
|
135
|
-
|
136
|
-
assert_equal("text/plain", object[:content_type])
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_list_objects
|
140
|
-
expected_object = some_object_name
|
141
|
-
|
142
|
-
result = @client.list_objects(some_bucket_name)
|
143
|
-
if result.items.nil?
|
144
|
-
raise StandardError.new("no objects found")
|
145
|
-
end
|
146
|
-
|
147
|
-
contained = result.items.any? { |object| object.name == expected_object }
|
148
|
-
assert_equal(true, contained, "expected object not present")
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_put_object_acl
|
152
|
-
object_name = new_object_name
|
153
|
-
@client.put_object(some_bucket_name, object_name, some_temp_file)
|
154
|
-
|
155
|
-
acl = {
|
156
|
-
:entity => "allUsers",
|
157
|
-
:role => "READER"
|
158
|
-
}
|
159
|
-
@client.put_object_acl(some_bucket_name, object_name, acl)
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_list_object_acl
|
163
|
-
object_name = new_object_name
|
164
|
-
acls = [
|
165
|
-
{
|
166
|
-
:entity => "allUsers",
|
167
|
-
:role => "READER"
|
168
|
-
},
|
169
|
-
{
|
170
|
-
:entity => "allAuthenticatedUsers",
|
171
|
-
:role => "READER"
|
172
|
-
}
|
173
|
-
]
|
174
|
-
@client.put_object(some_bucket_name, object_name, some_temp_file, :acl => acls)
|
175
|
-
|
176
|
-
result = @client.list_object_acl(some_bucket_name, object_name)
|
177
|
-
if result.items.nil?
|
178
|
-
raise StandardError.new("no object access controls found")
|
179
|
-
end
|
180
|
-
|
181
|
-
assert_operator(acls.length, :<=, result.items.length,
|
182
|
-
"expected at least #{acls.length} ACL items")
|
183
|
-
|
184
|
-
expected_acls = Hash[acls.map { |acl| [acl[:entity], acl[:role]] }]
|
185
|
-
num_found = 0
|
186
|
-
|
187
|
-
result.items.each do |actual_acl|
|
188
|
-
if expected_acls[actual_acl.entity] == actual_acl.role
|
189
|
-
num_found += 1
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
assert_equal(acls.length, num_found, "only found #{num_found} of #{acls.length} expected ACLs")
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_get_object_acl
|
197
|
-
object_name = new_object_name
|
198
|
-
@client.put_object(some_bucket_name, object_name, some_temp_file)
|
199
|
-
|
200
|
-
data = {
|
201
|
-
:entity => "allUsers",
|
202
|
-
:role => "READER"
|
203
|
-
}
|
204
|
-
@client.put_object_acl(some_bucket_name, object_name, data)
|
205
|
-
|
206
|
-
result = @client.get_object_acl(some_bucket_name, object_name, "allUsers")
|
207
|
-
if result.nil?
|
208
|
-
raise StandardError.new("expected object access control not found")
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_get_object_https_url
|
213
|
-
result = @client.get_object_https_url(some_bucket_name, some_object_name, 0)
|
214
|
-
assert_operator(result.length, :>, 0)
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_get_object_http_url
|
218
|
-
result = @client.get_object_http_url(some_bucket_name, some_object_name, 0)
|
219
|
-
assert_operator(result.length, :>, 0)
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_put_object_url
|
223
|
-
result = @client.put_object_url(some_bucket_name, new_object_name, 0)
|
224
|
-
assert_operator(result.length, :>, 0)
|
225
|
-
end
|
226
|
-
end
|
@@ -1,38 +0,0 @@
|
|
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_json_key_location = Fog.credentials[:google_json_key_location]
|
7
|
-
@google_json_key_string = File.open(File.expand_path(@google_json_key_location), "rb", &:read)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_authenticates_with_json_key_location
|
11
|
-
c = Fog::Google::Compute.new(:google_key_location => nil,
|
12
|
-
:google_key_string => nil,
|
13
|
-
:google_json_key_location => @google_json_key_location,
|
14
|
-
:google_json_key_string => nil)
|
15
|
-
assert_kind_of(Fog::Google::Compute::Real, c)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_authenticates_with_json_key_string
|
19
|
-
c = Fog::Google::Compute.new(:google_key_location => nil,
|
20
|
-
:google_key_string => nil,
|
21
|
-
:google_json_key_location => nil,
|
22
|
-
:google_json_key_string => @google_json_key_string)
|
23
|
-
assert_kind_of(Fog::Google::Compute::Real, c)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_raises_argument_error_when_google_project_is_missing
|
27
|
-
assert_raises(ArgumentError) { Fog::Google::Compute.new(:google_project => nil) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_raises_argument_error_when_google_keys_are_given
|
31
|
-
assert_raises(ArgumentError) do
|
32
|
-
Fog::Google::Compute.new(:google_key_location => nil,
|
33
|
-
:google_key_string => nil,
|
34
|
-
:google_json_key_location => nil,
|
35
|
-
:google_json_key_string => nil)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "helpers/test_helper"
|
2
|
-
|
3
|
-
class UnitTestCollections < Minitest::Test
|
4
|
-
def setup
|
5
|
-
Fog.mock!
|
6
|
-
|
7
|
-
@client = Fog::Compute.new(provider: "google",
|
8
|
-
google_project: "foo")
|
9
|
-
|
10
|
-
# Exceptions that do not pass test_common_methods:
|
11
|
-
#
|
12
|
-
# Projects do not have a "list" method in compute API, so 'all' is not implemented
|
13
|
-
@common_method_exceptions = [Fog::Google::Compute::Projects]
|
14
|
-
# Enumerate all descendants of Fog::Collection
|
15
|
-
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class).to_a
|
16
|
-
|
17
|
-
@collections = descendants.select { |d| d.name.match(/Fog::Google::Compute/) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def teardown
|
21
|
-
Fog.unmock!
|
22
|
-
end
|
23
|
-
|
24
|
-
# This tests whether Fog::Google::Compute collections have common lifecycle methods
|
25
|
-
def test_common_methods
|
26
|
-
subjects = @collections - @common_method_exceptions
|
27
|
-
subjects.each do |klass|
|
28
|
-
obj = klass.new
|
29
|
-
assert obj.respond_to?(:all), "#{klass} should have an .all method"
|
30
|
-
assert obj.respond_to?(:get), "#{klass} should have a .get method"
|
31
|
-
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_collection_get_arguments
|
36
|
-
@collections.each do |klass|
|
37
|
-
obj = klass.new
|
38
|
-
assert_operator(obj.method(:get).arity, :<=, 1,
|
39
|
-
"#{klass} should have at most 1 required parameter in get()")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "helpers/test_helper"
|
2
|
-
|
3
|
-
class UnitTestModels < Minitest::Test
|
4
|
-
def setup
|
5
|
-
Fog.mock!
|
6
|
-
@client = Fog::Compute.new(provider: "google",
|
7
|
-
google_project: "foo")
|
8
|
-
|
9
|
-
# Do not test models that do not have a create method in API
|
10
|
-
exceptions = [Fog::Google::Compute::MachineType,
|
11
|
-
Fog::Google::Compute::Region,
|
12
|
-
Fog::Google::Compute::DiskType,
|
13
|
-
Fog::Google::Compute::Operation,
|
14
|
-
Fog::Google::Compute::Zone,
|
15
|
-
Fog::Google::Compute::Snapshot,
|
16
|
-
Fog::Google::Compute::Project]
|
17
|
-
# Enumerate all descendants of Fog::Model
|
18
|
-
descendants = ObjectSpace.each_object(Fog::Model.singleton_class).to_a
|
19
|
-
|
20
|
-
@models = descendants.select { |d| d.name.match(/Fog::Google::Compute/) } - exceptions
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
Fog.unmock!
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_common_methods
|
28
|
-
# This tests whether Fog::Google::Compute models have common lifecycle methods
|
29
|
-
@models.each do |klass|
|
30
|
-
obj = klass.new
|
31
|
-
assert obj.respond_to?(:save), "#{klass} should have a .save method"
|
32
|
-
assert obj.respond_to?(:destroy), "#{klass} should have a .destroy method"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|