From 03937f9970f9e167ddf91f4cb107afdeed206d66 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 23 Aug 2022 00:12:19 +0000 Subject: [PATCH] fix: better support for fallback mode (#543) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 468790263 Source-Link: https://github.com/googleapis/googleapis/commit/873ab456273d105245df0fb82a6c17a814553b80 Source-Link: https://github.com/googleapis/googleapis-gen/commit/cb6f37aeff2a3472e40a7bbace8c67d75e24bee5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2I2ZjM3YWVmZjJhMzQ3MmU0MGE3YmJhY2U4YzY3ZDc1ZTI0YmVlNSJ9 --- .../os_login_service.delete_posix_account.js | 3 + .../os_login_service.delete_ssh_public_key.js | 3 + .../v1/os_login_service.get_login_profile.js | 3 + .../v1/os_login_service.get_ssh_public_key.js | 3 + .../os_login_service.import_ssh_public_key.js | 3 + .../os_login_service.update_ssh_public_key.js | 3 + ...ppet_metadata.google.cloud.oslogin.v1.json | 12 +- .../os_login_service.delete_posix_account.js | 3 + .../os_login_service.delete_ssh_public_key.js | 3 + .../os_login_service.get_login_profile.js | 3 + .../os_login_service.get_ssh_public_key.js | 3 + .../os_login_service.import_ssh_public_key.js | 3 + .../os_login_service.update_ssh_public_key.js | 3 + ..._metadata.google.cloud.oslogin.v1beta.json | 12 +- .../src/v1/os_login_service_client.ts | 3 +- .../src/v1beta/os_login_service_client.ts | 3 +- .../test/gapic_os_login_service_v1.ts | 160 +++++++++--------- .../test/gapic_os_login_service_v1beta.ts | 160 +++++++++--------- 18 files changed, 214 insertions(+), 172 deletions(-) diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js index 756c03d06c1b..9ffef6406c7c 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1_generated_OsLoginService_DeletePosixAccount_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js index 68fffcfaf18b..cf03e46e16d4 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1_generated_OsLoginService_DeleteSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js index eadc1b4087da..bfe9398c9030 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1_generated_OsLoginService_GetLoginProfile_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js index 5238c5c17682..d95414b4f9cb 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1_generated_OsLoginService_GetSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js index c058b899a31e..c6d826aa785d 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js @@ -23,6 +23,9 @@ function main(parent) { // [START oslogin_v1_generated_OsLoginService_ImportSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js index 86debd03143e..a9d5dc708c61 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name, sshPublicKey) { // [START oslogin_v1_generated_OsLoginService_UpdateSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json b/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json index 068af9034997..48925bdfdd46 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json +++ b/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -62,7 +62,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -102,7 +102,7 @@ "segments": [ { "start": 25, - "end": 58, + "end": 61, "type": "FULL" } ], @@ -150,7 +150,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -190,7 +190,7 @@ "segments": [ { "start": 25, - "end": 58, + "end": 61, "type": "FULL" } ], @@ -238,7 +238,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js index 08085911a2fe..8833aa395b40 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js index 621bdd467796..2dc7fdc4fa1b 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1beta_generated_OsLoginService_DeleteSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js index 56121215d8d1..97028d9fcd44 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1beta_generated_OsLoginService_GetLoginProfile_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_ssh_public_key.js index 4e89ec3ea658..7e901702ea9e 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name) { // [START oslogin_v1beta_generated_OsLoginService_GetSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js index eede91051909..d1af96117a47 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js @@ -23,6 +23,9 @@ function main(sshPublicKey) { // [START oslogin_v1beta_generated_OsLoginService_ImportSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.update_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.update_ssh_public_key.js index 83b7246042d3..ce67375a1b9f 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.update_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.update_ssh_public_key.js @@ -23,6 +23,9 @@ function main(name, sshPublicKey) { // [START oslogin_v1beta_generated_OsLoginService_UpdateSshPublicKey_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json b/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json index 896bcbe3f689..cc9106b51092 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -62,7 +62,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -102,7 +102,7 @@ "segments": [ { "start": 25, - "end": 58, + "end": 61, "type": "FULL" } ], @@ -150,7 +150,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -190,7 +190,7 @@ "segments": [ { "start": 25, - "end": 58, + "end": 61, "type": "FULL" } ], @@ -238,7 +238,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], diff --git a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts index 8b047e57daaa..44722ccf7986 100644 --- a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts @@ -242,7 +242,8 @@ export class OsLoginServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; diff --git a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts index 7afb55ac289a..ce868a6523f4 100644 --- a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts @@ -242,7 +242,8 @@ export class OsLoginServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts index 4961f885905a..292e8da25409 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts @@ -50,101 +50,103 @@ function stubSimpleCallWithCallback( } describe('v1.OsLoginServiceClient', () => { - it('has servicePath', () => { - const servicePath = - osloginserviceModule.v1.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + osloginserviceModule.v1.OsLoginServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = osloginserviceModule.v1.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient(); + assert(client); }); - client.initialize(); - assert(client.osLoginServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); }); - assert.strictEqual(client.osLoginServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osLoginServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('deletePosixAccount', () => { diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts index 1ac2e25accdd..78512e22daac 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts @@ -50,101 +50,103 @@ function stubSimpleCallWithCallback( } describe('v1beta.OsLoginServiceClient', () => { - it('has servicePath', () => { - const servicePath = - osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); + assert(client); }); - client.initialize(); - assert(client.osLoginServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); }); - assert.strictEqual(client.osLoginServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.osLoginServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('deletePosixAccount', () => {