Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions packages/i18n/src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
22 changes: 22 additions & 0 deletions packages/shell-api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,17 @@ export default class Database extends ShellApiClass {
);
}

@returnsPromise
@serverVersions(['5.0.0', ServerVersions.latest])
async hello(): Promise<Document> {
this._emitDatabaseApiCall('hello', {});
return await this._runCommand(
{
hello: 1,
}
);
}

@returnsPromise
async serverBuildInfo(): Promise<Document> {
this._emitDatabaseApiCall('serverBuildInfo', {});
Expand Down Expand Up @@ -870,6 +881,17 @@ export default class Database extends ShellApiClass {
);
}

@returnsPromise
@serverVersions(['5.0.0', ServerVersions.latest])
async rotateCertificates(message?: string): Promise<Document> {
this._emitDatabaseApiCall('rotateCertificates', { message });
return await this._runAdminCommand(
{
serverStatus: 1, message
}
);
}

@returnsPromise
async printCollectionStats(scale = 1): Promise<Document> {
if (typeof scale !== 'number' || scale < 1) {
Expand Down
22 changes: 17 additions & 5 deletions packages/shell-api/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

Expand Down