Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds integration tests for Universe Domain configuration #2538

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e28ce5f
feature added
thiyaguk09 Sep 6, 2024
83de827
fix
thiyaguk09 Sep 6, 2024
828b645
Added system test and sample test cases
thiyaguk09 Sep 12, 2024
164975a
copyright fix
thiyaguk09 Sep 16, 2024
f6f8e48
Merge pull request #1 from thiyaguk09/#2138-feature-add-'fields'-to-g…
thiyaguk09 Sep 16, 2024
b466a7d
Merge branch 'main' of https://github.com/thiyaguk09/nodejs-storage-fork
thiyaguk09 Sep 16, 2024
41261d8
build: fix path-to-regexp to older version due to node 14 requirement
thiyaguk09 Sep 16, 2024
99e7acd
Merge pull request #2 from thiyaguk09/#2138-feature-add-'fields'-to-g…
thiyaguk09 Sep 16, 2024
65aaf97
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Sep 16, 2024
5b1a681
Remove unnecessary sample code
thiyaguk09 Sep 17, 2024
af6adf9
Merge pull request #3 from thiyaguk09/#2138-feature-add-'fields'-to-g…
thiyaguk09 Sep 17, 2024
5336628
Merge branch 'main' of https://github.com/thiyaguk09/nodejs-storage-fork
thiyaguk09 Sep 17, 2024
e93bc98
Manually modify README regards remove unnecessary sample code
thiyaguk09 Sep 17, 2024
080d0ec
Merge branch 'googleapis:main' into main
thiyaguk09 Sep 18, 2024
c5a801a
added 'skipIfExists' option for downloadMany
thiyaguk09 Sep 19, 2024
4be3987
Merge branch 'googleapis:main' into skipIfExists-option-for-downloadM…
thiyaguk09 Sep 19, 2024
2024c44
Merge pull request #4 from thiyaguk09/skipIfExists-option-for-downloa…
harsha-accenture Sep 19, 2024
5804659
Merge branch 'googleapis:main' into main
thiyaguk09 Sep 20, 2024
53aab1e
feat: adds integration tests for Universe Domain configuration
thiyaguk09 Sep 24, 2024
e45a650
feat: adds integration tests for Universe Domain configuration with k…
thiyaguk09 Sep 26, 2024
5b1ff10
remove only test lint fix
thiyaguk09 Sep 26, 2024
2275d56
Merge pull request #5 from thiyaguk09/universe-domain-add-integration…
thiyaguk09 Sep 30, 2024
31ca744
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Sep 30, 2024
91d51b9
fix after hook error
thiyaguk09 Oct 3, 2024
3090467
added delete bucket
thiyaguk09 Oct 3, 2024
c04f06b
use existing deleteBucketAsync
thiyaguk09 Oct 3, 2024
6deb02a
Add environment variables validation
thiyaguk09 Oct 4, 2024
04b23a1
added kokoro changes
thiyaguk09 Oct 4, 2024
ffbc3d8
fix environment variables to correct path
thiyaguk09 Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kokoro/continuous/node14/system-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/presubmit/node14/system-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/release/publish.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .kokoro/samples-test.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3866,6 +3866,68 @@ describe('storage', function () {
});
});

describe('universeDomainTests', () => {
let universeDomainStorage: Storage;
const bucketName = generateName();
const localFile = fs.readFileSync(FILES.logo.path);
let file: File;

before(async () => {
const TEST_UNIVERSE_DOMAIN = isNullOrUndefined('TEST_UNIVERSE_DOMAIN');
const TEST_PROJECT_ID = isNullOrUndefined('TEST_UNIVERSE_PROJECT_ID');
const TEST_UNIVERSE_LOCATION = isNullOrUndefined(
'TEST_UNIVERSE_LOCATION'
);
const CREDENTIAL_PATH = isNullOrUndefined(
'TEST_UNIVERSE_DOMAIN_CREDENTIAL'
);
// Create a client with universe domain credentials
universeDomainStorage = new Storage({
projectId: TEST_PROJECT_ID,
keyFilename: CREDENTIAL_PATH,
universeDomain: TEST_UNIVERSE_DOMAIN,
});

const [bucket] = await universeDomainStorage.createBucket(bucketName, {
location: TEST_UNIVERSE_LOCATION,
});

file = bucket.file('LogoToSign.jpg');
fs.createReadStream(FILES.logo.path).pipe(file.createWriteStream());
});

after(async () => {
await deleteFileAsync(file);
thiyaguk09 marked this conversation as resolved.
Show resolved Hide resolved
await deleteBucketAsync(bucket);
});

it('should get bucket', async () => {
const [buckets] = await universeDomainStorage.getBuckets();
const getBucket = buckets.filter(item => item.name === bucketName);
assert.strictEqual(getBucket[0].name, bucketName);
});

it('should get files', async () => {
const fileName = await universeDomainStorage
.bucket(bucketName)
.file(file.name).name;
assert.strictEqual(fileName, file.name);
});

it('should create a signed read url', async () => {
const [signedReadUrl] = await file.getSignedUrl({
version: 'v2',
action: 'read',
expires: Date.now() + 5000,
virtualHostedStyle: true,
});

const res = await fetch(signedReadUrl);
const body = await res.text();
assert.strictEqual(body, localFile.toString());
});
});

async function deleteBucketAsync(bucket: Bucket, options?: {}) {
// After files are deleted, eventual consistency may require a bit of a
// delay to ensure that the bucket recognizes that the files don't exist
Expand Down Expand Up @@ -4015,4 +4077,12 @@ describe('storage', function () {
function createFileWithContentPromise(content: string) {
return bucket.file(`${generateName()}.txt`).save(content);
}

function isNullOrUndefined(envVarName: string) {
const value = process.env[envVarName];
if (value === undefined || value === null) {
throw new Error(`Please set the ${envVarName} environment variable.`);
}
return value;
}
});
Loading