Skip to content

Commit 5d45224

Browse files
more and delete old tests
1 parent e7fb4aa commit 5d45224

File tree

6 files changed

+16
-359
lines changed

6 files changed

+16
-359
lines changed

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ NOTE: The test suite requires an active kerberos deployment.
126126
## Functions
127127

128128
<dl>
129-
<dt><a href="#checkPassword">checkPassword(username, password, service, [defaultRealm])</a> ⇒ <code>Promise</code></dt>
129+
<dt><a href="#checkPassword">checkPassword(username, password, service, [defaultRealm])</a> ⇒ <code>Promise.&lt;null&gt;</code></dt>
130130
<dd><p>This function provides a simple way to verify that a user name and password
131131
match those normally used for Kerberos authentication.
132132
It does this by checking that the supplied user name and password can be
@@ -145,10 +145,10 @@ security could be compromised if you do.</p>
145145
<dd><p>This function returns the service principal for the server given a service type and hostname.</p>
146146
<p>Details are looked up via the <code>/etc/keytab</code> file.</p>
147147
</dd>
148-
<dt><a href="#initializeClient">initializeClient(service, [options])</a> ⇒ <code>Promise</code></dt>
148+
<dt><a href="#initializeClient">initializeClient(service, [options])</a> ⇒ <code><a href="#KerberosClient">Promise.&lt;KerberosClient&gt;</a></code></dt>
149149
<dd><p>Initializes a context for client-side authentication with the given service principal.</p>
150150
</dd>
151-
<dt><a href="#initializeServer">initializeServer(service)</a> ⇒ <code>Promise</code></dt>
151+
<dt><a href="#initializeServer">initializeServer(service)</a> ⇒ <code><a href="#KerberosServer">Promise.&lt;KerberosServer&gt;</a></code></dt>
152152
<dd><p>Initializes a context for server-side authentication with the given service principal.</p>
153153
</dd>
154154
</dl>
@@ -185,7 +185,6 @@ security could be compromised if you do.</p>
185185

186186
Processes a single kerberos client-side step using the supplied server challenge.
187187

188-
**Returns**: <code>Promise</code> - returns Promise
189188
<a name="KerberosClient+wrap"></a>
190189

191190
### *kerberosClient*.wrap(challenge, [options])
@@ -199,7 +198,6 @@ Processes a single kerberos client-side step using the supplied server challenge
199198

200199
Perform the client side kerberos wrap step.
201200

202-
**Returns**: <code>Promise</code> - returns Promise
203201
<a name="KerberosClient+unwrap"></a>
204202

205203
### *kerberosClient*.unwrap(challenge)
@@ -210,7 +208,6 @@ Perform the client side kerberos wrap step.
210208

211209
Perform the client side kerberos unwrap step
212210

213-
**Returns**: <code>Promise</code> - returns Promise
214211
<a name="KerberosServer"></a>
215212

216213
## KerberosServer
@@ -233,7 +230,6 @@ Perform the client side kerberos unwrap step
233230

234231
Processes a single kerberos server-side step using the supplied client data.
235232

236-
**Returns**: <code>Promise</code> - returns Promise
237233
<a name="checkPassword"></a>
238234

239235
## checkPassword(username, password, service, [defaultRealm])
@@ -261,7 +257,7 @@ IMPORTANT: This method is vulnerable to KDC spoofing attacks and it should
261257
only be used for testing. Do not use this in any production system - your
262258
security could be compromised if you do.
263259

264-
**Returns**: <code>Promise</code> - returns Promise
260+
**Returns**: <code>Promise.&lt;null&gt;</code> - returns Promise that rejects if the password is invalid
265261
<a name="principalDetails"></a>
266262

267263
## principalDetails(service, hostname)
@@ -290,7 +286,7 @@ Details are looked up via the `/etc/keytab` file.
290286

291287
Initializes a context for client-side authentication with the given service principal.
292288

293-
**Returns**: <code>Promise</code> - returns Promise
289+
**Returns**: [<code>Promise.&lt;KerberosClient&gt;</code>](#KerberosClient) - returns Promise
294290
<a name="initializeServer"></a>
295291

296292
## initializeServer(service)
@@ -301,4 +297,4 @@ Initializes a context for client-side authentication with the given service prin
301297

302298
Initializes a context for server-side authentication with the given service principal.
303299

304-
**Returns**: <code>Promise</code> - returns Promise
300+
**Returns**: [<code>Promise.&lt;KerberosServer&gt;</code>](#KerberosServer) - returns Promise

lib/kerberos.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const originalStep = KerberosClient.prototype.step;
3939
* @kind function
4040
* @memberof KerberosClient
4141
* @param {string} challenge A string containing the base64-encoded server data (which may be empty for the first step)
42-
* @return {Promise} returns Promise
42+
* @return {Promise<string>}
4343
*/
4444
KerberosClient.prototype.step = async function step(challenge) {
4545
return await promisify(originalStep.bind(this))(challenge);
@@ -55,7 +55,7 @@ const originalWrap = KerberosClient.prototype.wrap;
5555
* @param {object} [options] Optional settings
5656
* @param {string} [options.user] The user to authorize
5757
* @param {boolean} [options.protect] Indicates if the wrap should request message confidentiality
58-
* @return {Promise} returns Promise
58+
* @return {Promise<string>}
5959
*/
6060
KerberosClient.prototype.wrap = async function wrap(challenge, options = {}) {
6161
return await promisify(originalWrap.bind(this))(challenge, options);
@@ -68,7 +68,7 @@ const originalUnwrap = KerberosClient.prototype.unwrap;
6868
* @kind function
6969
* @memberof KerberosClient
7070
* @param {string} challenge A string containing the base64-encoded server data
71-
* @return {Promise} returns Promise
71+
* @return {Promise<string>}
7272
*/
7373
KerberosClient.prototype.unwrap = async function unwrap(challenge) {
7474
return await promisify(originalUnwrap.bind(this))(challenge);
@@ -90,7 +90,7 @@ const originalServerStep = KerberosServer.prototype.step;
9090
* @kind function
9191
* @memberof KerberosServer
9292
* @param {string} challenge A string containing the base64-encoded client data
93-
* @return {Promise} returns Promise
93+
* @return {Promise<KerberosServer>}
9494
*/
9595
KerberosServer.prototype.step = async function step(challenge) {
9696
return await promisify(originalServerStep.bind(this))(challenge);
@@ -118,7 +118,7 @@ KerberosServer.prototype.step = async function step(challenge) {
118118
* @param {string} password The password for the user.
119119
* @param {string} service The Kerberos service to check access for.
120120
* @param {string} [defaultRealm] The default realm to use if one is not supplied in the user argument.
121-
* @return {Promise} returns Promise
121+
* @return {Promise<null>} returns Promise that rejects if the password is invalid
122122
*/
123123
async function checkPassword(username, password, service, defaultRealm) {
124124
return await promisify(kerberos.checkPassword)(username, password, service, defaultRealm);
@@ -147,7 +147,7 @@ async function principalDetails(service, hostname) {
147147
* @param {string} [options.principal] Optional string containing the client principal in the form 'user@realm' (e.g. '[email protected]').
148148
* @param {number} [options.flags] Optional integer used to set GSS flags. (e.g. `GSS_C_DELEG_FLAG\|GSS_C_MUTUAL_FLAG\|GSS_C_SEQUENCE_FLAG` will allow for forwarding credentials to the remote host)
149149
* @param {number} [options.mechOID] Optional GSS mech OID. Defaults to None (GSS_C_NO_OID). Other possible values are `GSS_MECH_OID_KRB5`, `GSS_MECH_OID_SPNEGO`.
150-
* @return {Promise} returns Promise
150+
* @return {Promise<KerberosClient>} returns Promise
151151
*/
152152
async function initializeClient(service, options = { mechOID: GSS_C_NO_OID }) {
153153
return await promisify(kerberos.initializeClient)(service, options);
@@ -158,7 +158,7 @@ async function initializeClient(service, options = { mechOID: GSS_C_NO_OID }) {
158158
*
159159
* @kind function
160160
* @param {string} service A string containing the service principal in the form 'type@fqdn' (e.g. '[email protected]').
161-
* @return {Promise} returns Promise
161+
* @return {Promise<KerberosServer>} returns Promise
162162
*/
163163
async function initializeServer(service) {
164164
return await promisify(kerberos.initializeServer)(service);

package-lock.json

Lines changed: 1 addition & 146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@
4242
"eslint-plugin-prettier": "^5.5.4",
4343
"jsdoc-to-markdown": "^9.1.2",
4444
"mocha": "^11.7.1",
45-
"mongodb": "^6.18.0",
4645
"node-gyp": "^10.1.0",
4746
"prebuild": "^13.0.1",
48-
"prettier": "^3.6.2",
49-
"request": "^2.88.2"
47+
"prettier": "^3.6.2"
5048
},
5149
"overrides": {
5250
"prebuild": {

test/kerberos_tests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ describe('Kerberos', function () {
2727
it('should check a given password against a kerberos server', async function () {
2828
const service = `HTTP/${hostname}`;
2929

30-
// Test with correct password - should not throw
3130
await kerberos.checkPassword(username, password, service, realm.toUpperCase());
3231

33-
// Test with incorrect password - should throw
3432
const error = await kerberos
3533
.checkPassword(username, 'incorrect-password', service, realm.toUpperCase())
3634
.catch(e => e);
@@ -50,6 +48,7 @@ describe('Kerberos', function () {
5048
expect(client.contextComplete).to.be.false;
5149

5250
const serverResponse = await server.step(clientResponse);
51+
5352
expect(client.contextComplete).to.be.false;
5453

5554
await client.step(serverResponse);

0 commit comments

Comments
 (0)