Skip to content

Commit

Permalink
feat(NODE-5506): add Binary subtype sensitive (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Mar 12, 2024
1 parent 2ac17ec commit 748ca60
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/binary.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 8', () => {
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
Original file line number Diff line number Diff line change
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

0 comments on commit 748ca60

Please sign in to comment.