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(NODE-5506): add Binary subtype sensitive #657

Merged
merged 6 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/binary.ts
Expand Up @@ -56,6 +56,8 @@ export class Binary extends BSONValue {
static readonly SUBTYPE_ENCRYPTED = 6;
/** Column BSON type */
static readonly SUBTYPE_COLUMN = 7;
/** Sensitive BSON type */
static readonly SUBTYPE_SENSITIVE = 8;
/** User BSON type */
static readonly SUBTYPE_USER_DEFINED = 128;

Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Expand Up @@ -109,6 +109,9 @@ export const BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
/** Column BSON type @internal */
export const BSON_BINARY_SUBTYPE_COLUMN = 7;

/** Sensitive BSON type @internal */
export const BSON_BINARY_SUBTYPE_SENSITIVE = 8;

/** Binary User Defined Type @internal */
export const BSON_BINARY_SUBTYPE_USER_DEFINED = 128;

Expand Down
7 changes: 7 additions & 0 deletions test/node/constants.test.ts
Expand Up @@ -19,6 +19,8 @@ describe('BSON Constants', () => {
| "\x04" UUID
| "\x05" MD5
| "\x06" Encrypted BSON value
| "\x07" Column BSON value
| "\x08" Sensitive BSON value
| "\x80" User defined
*/
it('Default should be 0', () => {
Expand Down Expand Up @@ -55,6 +57,11 @@ describe('BSON Constants', () => {
expect(constants.BSON_BINARY_SUBTYPE_COLUMN).to.equal(7);
expect(Binary.SUBTYPE_COLUMN).to.equal(7);
});

it('Sensitive should be 7', () => {
aditi-khare-mongoDB marked this conversation as resolved.
Show resolved Hide resolved
expect(constants.BSON_BINARY_SUBTYPE_SENSITIVE).to.equal(8);
expect(Binary.SUBTYPE_SENSITIVE).to.equal(8);
});
});
context('BSON Type indicators', () => {
/*
Expand Down
5 changes: 5 additions & 0 deletions test/node/specs/bson-corpus/binary.json
Expand Up @@ -55,6 +55,11 @@
"canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}"
},
{
"description": "subtype 0x08",
"canonical_bson": "1D000000057800100000000873FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"08\"}}}"
},
{
"description": "subtype 0x80",
"canonical_bson": "0F0000000578000200000080FFFF00",
Expand Down