diff --git a/.kokoro/presubmit/acceptance.cfg b/.kokoro/presubmit/acceptance.cfg index 93a92eaa0842..232468f796ef 100644 --- a/.kokoro/presubmit/acceptance.cfg +++ b/.kokoro/presubmit/acceptance.cfg @@ -29,7 +29,7 @@ env_vars: { env_vars: { key: "SECRET_MANAGER_KEYS" - value: "" + value: "client-library-test-universe-domain, client-library-test-universe-project-id, client-library-test-universe-storage-location, client-library-test-universe-domain-credential" } env_vars: { diff --git a/google-cloud-storage/Gemfile b/google-cloud-storage/Gemfile index aa5496faa85e..a48936104d84 100644 --- a/google-cloud-storage/Gemfile +++ b/google-cloud-storage/Gemfile @@ -6,7 +6,6 @@ gem "google-cloud-core", path: "../google-cloud-core" gem "google-cloud-errors", path: "../google-cloud-errors" gem "google-cloud-pubsub", path: "../google-cloud-pubsub" gem "google-cloud-pubsub-v1", path: "../google-cloud-pubsub-v1" - gem "minitest-reporters", "~> 1.5.0", require: false gem "rake" diff --git a/google-cloud-storage/acceptance/storage/universe_domain_test.rb b/google-cloud-storage/acceptance/storage/universe_domain_test.rb new file mode 100644 index 000000000000..e958c6d2a2cb --- /dev/null +++ b/google-cloud-storage/acceptance/storage/universe_domain_test.rb @@ -0,0 +1,68 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "storage_helper" + +describe Google::Cloud::Storage, :universe_domain do + + # Fetch secret values from the secret_manager path + TEST_UNIVERSE_PROJECT_ID = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-project-id"))) + TEST_UNIVERSE_LOCATION = File.read(File.realpath(File.join(ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-storage-location"))) + TEST_UNIVERSE_DOMAIN = File.read(File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain"))) + TEST_UNIVERSE_DOMAIN_CREDENTIAL = File.realpath(File.join( ENV["KOKORO_GFILE_DIR"], "secret_manager", "client-library-test-universe-domain-credential")) + + let :ud_storage do + Google::Cloud::Storage.new( + project_id: TEST_UNIVERSE_PROJECT_ID, + credentials: TEST_UNIVERSE_DOMAIN_CREDENTIAL, + universe_domain: TEST_UNIVERSE_DOMAIN + ) + end + let(:t) { Time.now.utc.iso8601.gsub ":", "-" } + let(:ud_bucket_name) { "ud-test-ruby-bucket-#{t}-#{SecureRandom.hex(4)}".downcase } + + after do + ud_bucket = ud_storage.bucket ud_bucket_name + if ud_bucket + ud_bucket.files.all &:delete + safe_gcs_execute { ud_bucket.delete } + end + end + + it "creates a new bucket and uploads an object with universe_domain" do + # Create a bucket + ud_bucket = ud_storage.create_bucket ud_bucket_name, location: TEST_UNIVERSE_LOCATION + _(ud_bucket).wont_be_nil + _(ud_bucket.name).must_equal ud_bucket_name + + # Upload an object + ud_file_name = "ud-test-file" + ud_payload = StringIO.new "Hello world!" + ud_file = ud_bucket.create_file ud_payload, ud_file_name + _(ud_file.name).must_equal ud_file_name + + # Read the file uploaded + uploaded_ud_file = ud_bucket.file ud_file_name + _(uploaded_ud_file.name).must_equal ud_file_name + + # Delete the object + uploaded_ud_file.delete + _(uploaded_ud_file).must_be_nil + + # Delete the bucket + ud_bucket.delete + _(ud_bucket).must_be_nil + + end +end