Permalink
Browse files

fix LIST was not returning 'h' instead of dash for files

  • Loading branch information...
1 parent 5a694a3 commit 08ff59cf3cdc45bdf532f7ef3130c1750abb3cea @jfromaniello jfromaniello committed Apr 3, 2012
Showing with 65 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −0 fixture/jose/data.txt
  3. +1 −1 ftpd.js
  4. +14 −0 package.json
  5. +48 −0 specs/list.specs.js
View
@@ -0,0 +1 @@
+node_modules/*
View
@@ -0,0 +1 @@
+hola!
View
@@ -294,7 +294,7 @@ function createServer(host, sandbox) {
for (var i = 0; i < files.length; i++) {
var file = files[ i ];
var s = fs.statSync(path + file);
- var line = s.isDirectory() ? 'd' : 'h';
+ var line = s.isDirectory() ? 'd' : '-';
if (i > 0) pasvconn.write("\r\n");
line += (0400 & s.mode) ? 'r' : '-';
line += (0200 & s.mode) ? 'w' : '-';
View
@@ -0,0 +1,14 @@
+{
+ "name": "ftpd",
+ "version": "0.0.1",
+ "dependencies": {},
+ "devDependencies": {
+ "async": "~0.1.15",
+ "mocha": "~0.12.1",
+ "should": "~0.5.1",
+ "jsftp": "*"
+ },
+ "scripts": {
+ "test" : "mocha specs/* --globals commandArg"
+ }
+}
View
@@ -0,0 +1,48 @@
+require('should');
+var ftpd = require('../ftpd'), Ftp = require("jsftp");
+
+
+describe('application factory module', function(){
+ var ftp, server;
+
+ beforeEach(function(done){
+ server = ftpd.createServer("127.0.0.1", __dirname + '/../fixture');
+ server.on("client:connected", function(socket) {
+ var username;
+ socket.on("command:user", function(user, success, failure) {
+ if (user) {
+ username = user;
+ success();
+ } else failure();
+ });
+
+ socket.on("command:pass", function(pass, success, failure) {
+ if (pass) success(username);
+ else failure();
+ });
+ });
+ server.listen(2021);
+ ftp = new Ftp({
+ host: "127.0.0.1",
+ port: 2021
+ });
+ ftp.auth("jose", "esoj", function(err, res) {
+ done();
+ });
+ });
+
+ it("should return an application with port", function(done){
+ ftp.list("/", function(err, d){
+ var fileLine = d.substring(1).trim().split("\r\n")
+ .filter(function(line){
+ return line.indexOf("data.txt") !== -1;
+ })[0];
+ fileLine[0].should.eql("-");
+ done();
+ });
+ });
+
+ afterEach(function(){
+ server.close();
+ });
+});

0 comments on commit 08ff59c

Please sign in to comment.