Skip to content

Commit 308cf01

Browse files
committed
Merge branch 'master' into beta
2 parents 80e6cd8 + 290e57d commit 308cf01

File tree

6 files changed

+220
-7
lines changed

6 files changed

+220
-7
lines changed

.github/CODE_OF_CONDUCT.md

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at:
63+
64+
* write a email to <[email protected]> and <[email protected]>
65+
* write a DM to a maintainer [in our discord](https://discord.gg/bgCrRP9)
66+
67+
All complaints will be reviewed and investigated promptly and fairly.
68+
69+
All community leaders are obligated to respect the privacy and security of the
70+
reporter of any incident.
71+
72+
## Enforcement Guidelines
73+
74+
Community leaders will follow these Community Impact Guidelines in determining
75+
the consequences for any action they deem in violation of this Code of Conduct:
76+
77+
### 1. Correction
78+
79+
**Community Impact**: Use of inappropriate language or other behavior deemed
80+
unprofessional or unwelcome in the community.
81+
82+
**Consequence**: A private, written warning from community leaders, providing
83+
clarity around the nature of the violation and an explanation of why the
84+
behavior was inappropriate. A public apology may be requested.
85+
86+
### 2. Warning
87+
88+
**Community Impact**: A violation through a single incident or series
89+
of actions.
90+
91+
**Consequence**: A warning with consequences for continued behavior. No
92+
interaction with the people involved, including unsolicited interaction with
93+
those enforcing the Code of Conduct, for a specified period of time. This
94+
includes avoiding interactions in community spaces as well as external channels
95+
like social media. Violating these terms may lead to a temporary or
96+
permanent ban.
97+
98+
### 3. Temporary Ban
99+
100+
**Community Impact**: A serious violation of community standards, including
101+
sustained inappropriate behavior.
102+
103+
**Consequence**: A temporary ban from any sort of interaction or public
104+
communication with the community for a specified period of time. No public or
105+
private interaction with the people involved, including unsolicited interaction
106+
with those enforcing the Code of Conduct, is allowed during this period.
107+
Violating these terms may lead to a permanent ban.
108+
109+
### 4. Permanent Ban
110+
111+
**Community Impact**: Demonstrating a pattern of violation of community
112+
standards, including sustained inappropriate behavior, harassment of an
113+
individual, or aggression toward or disparagement of classes of individuals.
114+
115+
**Consequence**: A permanent ban from any sort of public interaction within
116+
the community.
117+
118+
## Attribution
119+
120+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
121+
version 2.0, available at
122+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
123+
124+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
125+
enforcement ladder](https://github.com/mozilla/diversity).
126+
127+
[homepage]: https://www.contributor-covenant.org
128+
129+
For answers to common questions about this code of conduct, see the FAQ at
130+
<https://www.contributor-covenant.org/faq>. Translations are available at
131+
<https://www.contributor-covenant.org/translations>.

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ also "disable" has been removed
165165
* **typescript:** upgrade to version 5.0.4 ([d531dde](https://github.com/nodkz/mongodb-memory-server/commit/d531ddea767cef2c038e228597812507e0590c2a))
166166
* **uuid:** remove package ([41b2551](https://github.com/nodkz/mongodb-memory-server/commit/41b2551a89df0eb806511efb85d5bd5f6419664c))
167167

168+
## [8.15.1](https://github.com/nodkz/mongodb-memory-server/compare/v8.15.0...v8.15.1) (2023-08-17)
169+
170+
171+
### Fixes
172+
173+
* fix binary download on debian testing/unstable ([#787](https://github.com/nodkz/mongodb-memory-server/issues/787)) ([1a8ac8a](https://github.com/nodkz/mongodb-memory-server/commit/1a8ac8a462d4d2cc2c9f99b5f8dc2e97ef224953))
174+
175+
176+
### Style
177+
178+
* **MongoBinaryDownloadUrl:** add comment explaining pr 787 ([1821135](https://github.com/nodkz/mongodb-memory-server/commit/1821135b7c59009455992e9a4f064ec46ba381f5))
179+
168180
## [8.15.0](https://github.com/nodkz/mongodb-memory-server/compare/v8.14.0...v8.15.0) (2023-08-15)
169181

170182

README.md

+26-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ All options are optional.
117117

118118
```js
119119
const mongod = new MongoMemoryServer({
120-
instance: {
120+
instance?: {
121121
port?: number, // by default choose any free port
122122
ip?: string, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`,
123123
dbName?: string, // by default '' (empty string)
@@ -126,14 +126,36 @@ const mongod = new MongoMemoryServer({
126126
replSet?: string, // by default no replica set, replica set name
127127
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
128128
},
129-
binary: {
129+
binary?: {
130130
version?: string, // by default '6.0.9'
131-
downloadDir?: string, // by default node_modules/.cache/mongodb-memory-server/mongodb-binaries
131+
downloadDir?: string, // see the documentation on what is chosen by default https://nodkz.github.io/mongodb-memory-server/docs/api/config-options#download_dir
132132
platform?: string, // by default os.platform()
133133
arch?: string, // by default os.arch()
134134
checkMD5?: boolean, // by default false OR process.env.MONGOMS_MD5_CHECK
135135
systemBinary?: string, // by default undefined or process.env.MONGOMS_SYSTEM_BINARY
136136
},
137+
// using "auth" will manage "instance.auth"
138+
auth?: {
139+
disable?: boolean, // disable automatic auth creation
140+
customRootName?: string, // by default "mongodb-memory-server-root"
141+
customRootPwd?: string, // by default "rootuser"
142+
force?: boolean, // force creation of users
143+
keyfileContent?: string, // by default "0123456789"
144+
extraUsers?: [{
145+
// see mongodb documentation https://docs.mongodb.com/manual/reference/method/db.createUser/#definition)
146+
createUser: string, // user name
147+
pwd: string, // user password
148+
roles: UserRoles[], // user roles
149+
database?: string, // which database the user is created on
150+
customData?: Record<string, any>,
151+
mechanisms?: ('SCRAM-SHA-1' | 'SCRAM-SHA-256')[],
152+
authenticationRestrictions?: {
153+
clientSource?: string;
154+
serverAddress?: string;
155+
}[],
156+
digestPassword?: boolean,
157+
}],
158+
},
137159
});
138160
```
139161

@@ -172,7 +194,7 @@ const replSet = new MongoMemoryReplSet({
172194
// unless otherwise noted below these values will be in common with all instances spawned:
173195
replSet: {
174196
name, // replica set name (default: 'testset')
175-
auth, // enable auth support? (default: undefined / disabled)
197+
auth?: boolean | AutomaticAuth, // enable auth, for options see #available-options-for-mongomemoryserver
176198
args, // any args specified here will be combined with any per instance args from `instanceOpts`
177199
count, // number of additional `mongod` processes to start (will not start any extra if instanceOpts.length > replSet.count); (default: 1)
178200
dbName, // default database for db URI strings. (default: uuid.v4())

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
282282
throw new UnknownVersionError(this.version);
283283
}
284284

285-
if (release >= 11 || ['unstable', 'testing'].includes(os.release)) {
285+
// without any "release"(empty string), fallback to testing
286+
// see https://tracker.debian.org/news/1433360/accepted-base-files-13-source-into-unstable/
287+
const isTesting = ['unstable', 'testing', ''].includes(os.release);
288+
289+
if (isTesting || release >= 11) {
286290
// Debian 11 is compatible with the binaries for debian 10
287291
// but does not have binaries for before 5.0.8
288292
// and only set to use "debian10" if the requested version is not a latest version
@@ -302,10 +306,10 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
302306
name += '71';
303307
}
304308

305-
if (release >= 10) {
309+
if (isTesting || release >= 10) {
306310
if (semver.lt(coercedVersion, '4.2.1') && !testVersionIsLatest(this.version)) {
307311
throw new KnownVersionIncompatibilityError(
308-
`Debian ${release}`,
312+
`Debian ${release || os.release || os.codename}`,
309313
this.version,
310314
'>=4.2.1',
311315
'Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release'

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts

+39
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,22 @@ describe('MongoBinaryDownloadUrl', () => {
555555
);
556556
});
557557

558+
it('for debian testing/unstable', async () => {
559+
const du = new MongoBinaryDownloadUrl({
560+
platform: 'linux',
561+
arch: 'x64',
562+
version: '5.0.9',
563+
os: {
564+
os: 'linux',
565+
dist: 'debian',
566+
release: '',
567+
},
568+
});
569+
expect(await du.getDownloadUrl()).toBe(
570+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian11-5.0.9.tgz'
571+
);
572+
});
573+
558574
it('should throw a Error when the provided version could not be coerced [UnknownVersionError]', async () => {
559575
const du = new MongoBinaryDownloadUrl({
560576
platform: 'linux',
@@ -636,6 +652,29 @@ describe('MongoBinaryDownloadUrl', () => {
636652
expect(err.message).toMatchSnapshot();
637653
}
638654
});
655+
656+
it('should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError]', async () => {
657+
const du = new MongoBinaryDownloadUrl({
658+
platform: 'linux',
659+
arch: 'x64',
660+
version: '4.0.25',
661+
os: {
662+
os: 'linux',
663+
dist: 'debian',
664+
codename: 'trixie',
665+
release: '',
666+
},
667+
});
668+
669+
try {
670+
await du.getDownloadUrl();
671+
fail('Expected to throw a KnownVersionIncompatibilityError');
672+
} catch (err) {
673+
assertIsError(err);
674+
expect(err).toBeInstanceOf(KnownVersionIncompatibilityError);
675+
expect(err.message).toMatchSnapshot();
676+
}
677+
});
639678
});
640679

641680
// for arch and arch based systems (no specific extra mapping)

packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoBinaryDownloadUrl.test.ts.snap

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should thr
1010
Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release"
1111
`;
1212

13+
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should throw a Error when requesting a version below 4.2.1 for debian testing [KnownVersionIncompatibilityError] 1`] = `
14+
"Requested Version \\"4.0.25\\" is not available for \\"Debian trixie\\"! Available Versions: \\">=4.2.1\\"
15+
Mongodb does not provide binaries for versions before 4.2.1 for Debian 10+ and also cannot be mapped to a previous Debian release"
16+
`;
17+
1318
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for debian should throw a Error when the provided version could not be coerced [UnknownVersionError] 1`] = `"Could not corece VERSION to a semver version (version: \\"vvv\\")"`;
1419

1520
exports[`MongoBinaryDownloadUrl getDownloadUrl() for linux for rhel should Error when ARM64 and rhel below 8 [KnownVersionIncompatibilityError] 1`] = `

0 commit comments

Comments
 (0)