Skip to content

Commit

Permalink
Basic tests + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Mar 23, 2017
1 parent bc04bfd commit f78953b
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 44 deletions.
4 changes: 2 additions & 2 deletions documentation/forum_bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const NntpGroup = new Schema({
min_index: { type: Number, default: 0 },
// Max visible post index
max_index: { type: Number, default: 0 },
// Last update time
last_ts: Date
// Create time
create_ts: { type: Date, default: Date.now }
},
{
versionKey : false
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/authinfo_pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {

session.authinfo_pass = cmd.match(CMD_RE)[1];

return session.server.authenticate(session)
return session.server._authenticate(session)
.then(success => {
if (!success) {
session.authinfo_user = null;
Expand Down
5 changes: 4 additions & 1 deletion lib/commands/authinfo_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module.exports = {
run(session, cmd) {
if (session.authenticated) return status._502_CMD_UNAVAILABLE;

if (!session.secure) return status._483_NOT_SECURE;
if (!session.server.options.secure &&
!session.secure) {
return status._483_NOT_SECURE;
}

session.authinfo_user = cmd.match(CMD_RE)[1];

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
run(session, cmd) {
// Reject all params. All extentions are in separate files
// and detected before this one.
if (cmd.match(CMD_RE).length > 1) return status._501_SYNTAX_ERROR;
if (cmd.match(CMD_RE)[2]) return status._501_SYNTAX_ERROR;

return session.server._getGroups(session)
.then(groups =>
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/list_active.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
run(session, cmd) {
let wildmat = cmd.match(CMD_RE)[2];

return session.server._getGroups(session, wildmat)
return session.server._getGroups(session, 0, wildmat)
.then(groups =>
[ status._215_INFO_FOLLOWS ]
.concat(groups.map(g => `${g.name} ${g.min_index} ${g.max_index} n`))
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/listgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
let g = session.group;

let result = [
`${status._211_GRP_SELECTED} {$g.total} {$g.min_index} {$g.max_index} ${name} list follows`
`${status._211_GRP_SELECTED} ${g.total} ${g.min_index} ${g.max_index} ${name} list follows`
];

//
Expand Down
16 changes: 16 additions & 0 deletions lib/commands/mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://tools.ietf.org/html/rfc3977#section-3.4.2
//
// Just a stub to not return errors on "MODE READER"
//
'use strict';


module.exports = {
head: 'MODE',
validate: /^MODE( [^\s]+)$/i,

// All supported params are defined in separate files
run() {
return '501 Unknown MODE option';
}
};
5 changes: 3 additions & 2 deletions lib/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ module.exports = {
_412_GRP_NOT_SLCTD : '412 No newsgroup has been selected',
_420_ARTICLE_NOT_SLCTD : '420 No current article has been selected',
_423_NO_ARTICLE_BY_NUM : '423 No such article number in this group',
_430_NO_ARTICLE_BY_ID : '423 No such article Found',
_430_NO_ARTICLE_BY_ID : '430 No such article Found',
_480_AUTH_REQUIRED : '480 Authentication required',
_481_AUTH_REJECTED : '481 Authentication rejected',
_483_NOT_SECURE : '483 Secure connection required',
_481_AUTH_BLACKLIST : '481 Authentication rejected (too many attempts)',
_482_AUTH_OUT_OF_SEQ : '482 Authentication commands issued out of sequence',
_500_CMD_UNKNOWN : '500 Command not recognized',
_501_SYNTAX_ERROR : '501 Command syntax error',
_502_CMD_UNAVAILABLE : '502 Command unavailable'
_502_CMD_UNAVAILABLE : '502 Command unavailable',
_503_NOT_SUPPORTED : '503 Feature not supported'
};
Loading

0 comments on commit f78953b

Please sign in to comment.