diff --git a/packages/i18n/src/locales/en_US.ts b/packages/i18n/src/locales/en_US.ts index 237d8f2123..2c59e57b16 100644 --- a/packages/i18n/src/locales/en_US.ts +++ b/packages/i18n/src/locales/en_US.ts @@ -1146,6 +1146,16 @@ const translations: Catalog = { description: 'Calls the isMaster command', example: 'db.isMaster()' }, + hello: { + link: 'https://docs.mongodb.com/manual/reference/method/db.hello', + description: 'Calls the hello command', + example: 'db.hello()' + }, + rotateCertificates: { + link: 'https://docs.mongodb.com/manual/reference/method/db.rotateCertificates', + description: 'Calls the rotateCertificates command', + example: 'db.rotateCertificates()' + }, serverBuildInfo: { link: 'https://docs.mongodb.com/manual/reference/method/db.serverBuildInfo', description: 'returns the db serverBuildInfo. uses the buildInfo command', diff --git a/packages/shell-api/src/database.ts b/packages/shell-api/src/database.ts index d0de0692fa..449e14733c 100644 --- a/packages/shell-api/src/database.ts +++ b/packages/shell-api/src/database.ts @@ -819,6 +819,17 @@ export default class Database extends ShellApiClass { ); } + @returnsPromise + @serverVersions(['5.0.0', ServerVersions.latest]) + async hello(): Promise { + this._emitDatabaseApiCall('hello', {}); + return await this._runCommand( + { + hello: 1, + } + ); + } + @returnsPromise async serverBuildInfo(): Promise { this._emitDatabaseApiCall('serverBuildInfo', {}); @@ -870,6 +881,17 @@ export default class Database extends ShellApiClass { ); } + @returnsPromise + @serverVersions(['5.0.0', ServerVersions.latest]) + async rotateCertificates(message?: string): Promise { + this._emitDatabaseApiCall('rotateCertificates', { message }); + return await this._runAdminCommand( + { + serverStatus: 1, message + } + ); + } + @returnsPromise async printCollectionStats(scale = 1): Promise { if (typeof scale !== 'number' || scale < 1) { diff --git a/packages/shell-api/src/integration.spec.ts b/packages/shell-api/src/integration.spec.ts index 8d04cfedbc..2b83bb02cf 100644 --- a/packages/shell-api/src/integration.spec.ts +++ b/packages/shell-api/src/integration.spec.ts @@ -1922,11 +1922,23 @@ describe('Shell API (integration)', function() { }); }); }); - describe('Field-level encryption', () => { - // This test is temporary and can go away once we actually implement FLE - // functionality. - it('native addon is present', () => { - expect(typeof serviceProvider.fle.ClientEncryption).to.equal('function'); + + describe('database commands', () => { + it('db.isMaster() works', async() => { + expect((await database.isMaster()).ismaster).to.equal(true); + }); + + context('with 5.0+ server', () => { + skipIfServerVersion(testServer, '<= 4.4'); + + it('db.hello() works', async() => { + expect((await database.hello()).isWritablePrimary).to.equal(true); + }); + + it('db.rotateCertificates() works', async() => { + expect((await database.rotateCertificates()).ok).to.equal(1); + expect((await database.rotateCertificates('message')).ok).to.equal(1); + }); }); });