Example #1
0
 it('should say no update is required', () => {
   nocked.get('/dustinblackman/Championify/master/package.json').reply(200, pkg);
   return updateManager.check().spread((version, major) => {
     version.should.equal(false);
     major.should.equal(false);
   });
 });
Example #2
0
File: list.js Project: Aetet/lmd
module.exports = function (cli, argv, cwd) {
    if (!init.check(cli, cwd)) {
        return;
    }

    listOfFiles(cli, cwd);
};
Example #3
0
    autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
        var test = require(nodePath.join(dir, 'test.js'));

        if (test.check) {
            test.check(taglibFinder, helpers);
        } else {
            if (test.before) {
                test.before(taglibFinder);
            }

            var finderDir = nodePath.join(dir, test.dir);
            var found = taglibFinder.find(finderDir, []).map(taglib => {
                if (taglib.path.startsWith(dir)) {
                    return taglib.path.substring(dir.length).replace(/[\\]/g, '/');
                } else {
                    return 'BAD:' + taglib.path;
                }
            });

            helpers.compare(found, '.json');

            if (test.after) {
                test.after(taglibFinder);
            }
        }

        return done();
    });
Example #4
0
                .then((lassoPageResult) => {
                    writeTestHtmlPage(lassoPageResult, nodePath.join(buildDir, pageName + '/test.html'));

                    if (main.checkError) {
                        var err;
                        try {
                            sandboxLoad(lassoPageResult);
                        } catch(_err) {
                            err = _err;
                        }

                        if (err) {
                            try {
                                main.checkError(err);
                            } catch(e) {
                                return done(e);
                            }
                            done();
                        } else {
                            done(new Error('Error expected'));
                        }
                    } else {
                        var sandbox = sandboxLoad(lassoPageResult);
                        main.check(sandbox.window);
                        done();
                    }

                })
Example #5
0
 it('should say a major update is required', () => {
   pkg.devDependencies['electron-prebuilt'] = '100.0.0';
   nocked.get('/dustinblackman/Championify/master/package.json').reply(200, pkg);
   nocked.get('/dustinblackman/Championify/master/package.json').reply(200, pkg);
   return updateManager.check().spread((version, major) => {
     version.should.equal(pkg.version);
     major.should.equal(true);
   });
 });
        async function(dir, helpers, done) {
            var testName = nodePath.basename(dir);
            var outputDir = nodePath.join(buildDir, testName);

            rmdirRecursive(outputDir);

            var lassoConfig = {
                urlPrefix: './',
                outputDir: outputDir,
                require: {
                    transforms: [
                        lassoBabelTransform
                    ]
                },
                fingerprintsEnabled: false,
                bundlingEnabled: false
            };

            var myLasso = lasso.create(lassoConfig);

            var lassoOptions = {};
            lassoOptions.pageName = testName;
            lassoOptions.from = dir;
            lassoOptions.dependencies = [
                'require-run: ' + nodePath.join(dir, 'client.js')
            ];

            const lassoPageResult = await myLasso.lassoPage(lassoOptions);
            var modulesRuntimeGlobal = myLasso.config.modulesRuntimeGlobal;

            var sandbox = sandboxLoad(lassoPageResult, modulesRuntimeGlobal);
            sandbox.$outputDir = lassoConfig.outputDir;

            var check = require(nodePath.join(dir, 'test.js')).check;

            if (check.length === 2) {
                check(sandbox.window, done);
            } else {
                check(sandbox.window);
                done();
            }
        }
Example #7
0
exports.handler = function handler (context) {

  if (context.user) {
    role.getRoles(context.user.id, context.meta.domain, function (error, roles) {
      if (error) {
        return context.fail(error);
      }

      context.resolve(roles, 200);
    });
    return;
  }

  if (!context.data.body.identifier) {
    return context.fail('Missing Identifier', 400);
  }

  if (!identifier.isEmail(context.data.body.identifier)) {
    return context.fail('Malformed Identifier', 400);
  }

  if (!context.data.body.secret) {
    return context.fail('Missing Challenge Secret', 400);
  }

  challenge.check(context, function (error, challengeMastered) {
    if (error) {
      return context.fail(error);
    }

    challenge.lock(context, challengeMastered, function () {
      if (challengeMastered) {
        user.select(context.data.body.identifier, function (error, userInfo) {
          if (error) {
            return context.fail(error);
          }

          context.user = userInfo;

          role.getRoles(userInfo.id, context.meta.domain, function (error, roles) {
            if (error) {
              return context.fail(error);
            }

            context.resolve(roles, 200);
          });
        });
      }
      else {
        context.fail('Challenge failed', 401);
      }
    });
  });
};
Example #8
0
function check(size, alignment, offset) {
  let buf = binding.alloc(size, alignment, offset);
  let slice = buf.slice(size >>> 1);

  buf = null;
  binding.check(slice);
  slice = null;
  global.gc();
  global.gc();
  global.gc();
}
Example #9
0
module.exports = function (cli, argv, cwd) {
    argv = optimist.parse(argv);

    var status,
        buildName = argv._[1];

    delete argv._;
    delete argv.$0;

    if (!init.check(cli, cwd)) {
        return;
    }

    if (!buildName) {
        printHelp(cli);
        return;
    }

    status = create.checkFile(cwd, buildName);

    if (status !== true) {
        printHelp(cli, status === false ? 'build `' + buildName + '` is not exists' : status);
        return;
    }


    var extraFlags = Object.keys(argv);

    if (extraFlags.length) {
        cli.ok('');
        cli.ok('Build `' + buildName +  '` (.lmd/' + buildName + '.lmd.json) updated');
        cli.ok('');

        cli.ok('These options are changed'.cyan.bold + ':');
        cli.ok('');

        var offset = extraFlags.reduce(function (longest, current) {
            return current.length > longest ? current.length : longest;
        }, 0);

        offset += 3;

        extraFlags.forEach(function (flagName) {
            var spaces = new Array(offset - flagName.length).join(' ');

            cli.ok('  ' + flagName.green + spaces + JSON.stringify(argv[flagName]));
        });
        cli.ok('');

        updateBuild(cwd, buildName, argv);
    } else {
        printHelp(cli);
    }
};
Example #10
0
router.use('/', function(req, res, next) {
	if (req.method == 'GET') {
		res.connection.setTimeout(0);
		if (init.check() == 0) {
			init.vulnUpdate(function() {
				next();
			});
		} else {
			next();
		}
	}
});
Example #11
0
            .action(function(cmd) {
                if (!task.check(cmd)) {
                    cmd.help();
                }
                task.action(cmd, function(err) {
                    if (!err) {
                        _this.logger.success('finish: ', task.name);
                    } else {
                        _this.logger.error('failed: ', err);
                    }

                });
            });
Example #12
0
    this.check = function () {
        var Checker = require('./formalisms/' + project.formalism + '/checker');

        for (var name in _models) {
            var checker = new Checker(_models[name]);

            try {
                checker.check();
            } catch (e) {
                console.log(e);
            }
        }
    };
Example #13
0
        function (dir, helpers, done) {
            var name = nodePath.basename(dir);
            var outputDir = nodePath.join(buildDir, name);
            rmdirRecursive(outputDir);
            helpers.getName = function() {
                return name;
            };
            helpers.getOutputDir = function() {
                return outputDir;
            };

            var main = require(nodePath.join(dir, 'test.js'));
            main.check(lasso, helpers, done);
        });
Example #14
0
                .then((lassoPageResult) => {
                    if (checkError) {
                        return done('Error expected');
                    }

                    if (main.check) {
                        main.check(lassoPageResult, helpers);
                    } else {
                        var css = fs.readFileSync(lassoPageResult.getCSSFiles()[0], { encoding: 'utf8' });
                        helpers.compare(css, '.css');
                    }

                    lasso.flushAllCaches(done);
                })
Example #15
0
process.app.get(/^\/type\/(.+)\/(https?:\/\/.+)/, function(req, res){
  var app_root = (req.connection.encrypted ? 'https' : 'http') + '://' + req.headers['host'];

  var type = req.params[0];
  var url = req.params[1];
  checker.check(url, new RegExp('^'+type), function(ok){
    if(ok) res.redirect(url);
    else{
      if(type.match(/^image/i)) res.redirect(app_root+'/images/invalid.png');
      else res.send('content type error', 415);
    }
  }, function(err, code){
    if(type.match(/^image/i)) res.redirect(app_root+'/images/invalid.png');
    else res.send('error('+code+')', 500);
  });
});
Example #16
0
        it('should return right message length', () => {
            const filePath = path.join(__dirname, '../fixture/leading-zero.less');
            const fileContent = fs.readFileSync(
                path.join(__dirname, '../fixture/leading-zero.less'),
                'utf8'
            ).replace(/\r\n?/g, '\n');

            const file = {
                path: filePath,
                content: fileContent
            };

            const errors = [];
            return checker.check(file, errors, () => {}).then(() => {
                expect(errors[0].messages.length).to.equal(14);
            });
        });
Example #17
0
        it('should return right message length', () => {
            // 清空 config storage,设置成默认的 config
            // 因为 fixture 目录下的 .lesslintrc 中配置了 import: false
            config.clearStorage();
            config.loadConfig('.', true);

            const filePath = path.join(__dirname, '../fixture/import.less');
            const fileContent = fs.readFileSync(
                path.join(__dirname, '../fixture/import.less'),
                'utf8'
            ).replace(/\r\n?/g, '\n');

            const file = {
                path: filePath,
                content: fileContent
            };

            const errors = [];
            return checker.check(file, errors, () => {}).then(() => {
                expect(errors[0].messages.length).to.equal(6);
            });
        });
Example #18
0
		authenticate: function(username,password){
			
			user_session.check(username,function(result){
				if (result===false)
					{
						req.session.authenticated = false;
						req.session.save();
						res({'auth_result':'fail'});
					}else{
							database.findOne('users',{username: username},function(result){
							if (!result)
								{
									req.session.authenticated = false;
									req.session.save();
									res({'auth_result':'fail'});
								}else{
									var salt = result.salt;
									var hashed_password = crypto.pbkdf2_hash(password,salt,500);
									
									if (hashed_password==result.password)
										{
											req.session.authenticated = true;
											req.session.username = username;
											req.session.save();
											res({'auth_result':'success'});
										}else{
											req.session.authenticated = false;
											req.session.save();
											res({'auth_result':'fail'});
										}
									
								}
						});
					}
			});
			
			//res({'AUTH':'SUCCESS'});
		},
Example #19
0
shcall.fillSession = function (sess, req, res, cb) {
  req.session = {valid: false, error: sh.error("session-bad", "missing session data")};

  if (_.isUndefined(sess)) {
    return cb(1);
  }
  if (!session.check(sess)) {
    req.session.error = sh.error("session-bad", "bad session data");
    return cb(1);
  }
  var uid = sess.split(":")[1];
  shlog.info("shcall", "loading user: uid = " + uid);
  req.loader.get("kUser", uid, _w(cb, function (error, user) {
    if (error) {
      req.session.error = sh.error("user-load", "unable to load user", {uid: uid, error: error, user: user});
      return cb(1);
    }
    shlog.info("shcall", "user loaded: " + uid);
    req.session.valid = true;
    req.session.uid = uid;
    req.session.user = user;
    cb(0);
  }));
};
Example #20
0
 it("can identify 'thing' correctly", function() {
     var mandg = require(`../lib/types/${name}.js`);
     assert.isTrue(mandg.check(thing));
 });
Example #21
0
let auth =  new oauth();

router.get(config.oauth.returnPath, (req, res, next) => {
    auth.callback(req).then(result => {
        if (!result.ok) {
            next('login failed');
        }
        return auth.login(req, result).then(() => {
            res.redirect(result.returnTo);
        });
    }).catch((ex) => {
        next('login failed: ' + ex.err);
    }).done();
});

router.get('/logout', auth.check(), auth.logout);

router.get('/login', auth.check(), (req, res) => {
    res.redirect('/');
});

router.get('/admin', auth.check('admin_page_acl'), (req, res) => {
    userStore.getAccessControl('admin_page_acl').then((acl) => {
        res.render('admin.html', { title: 'Administration page', acl: acl, login: req.isAuthenticated() ? req.user : undefined });
    });
});

router.get('/work', auth.check(), (req, res) => {
    res.render('work.html', { title: 'Work page', login: req.isAuthenticated() ? req.user : undefined });
});
Example #22
0
 autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
     var test = require(nodePath.join(dir, 'test.js'));
     test.check(marko, markoCompiler, expect, helpers, done);
 }, { timeout: 10000 });
Example #23
0
TopSDK.prototype.exec = function(apiName, params, cb) {
	try {
		var api = require('./request/' + apiName + '.js');
	} catch (e) {
		return this.logError(e);;
	}
	var request = new api(),
		sysParams = {},
		apiParams = {},
		allParams = {};
	for (var key in params) {
		if (request['set' + key.substring(0,1).toUpperCase() + key.substring(1)]) {
			request['set' + key.substring(0,1).toUpperCase() + key.substring(1)](params[key]);
		}
	}
	// 参数完整性检查
	if (this.checkRequest) {
		try {
			request.check(topApiCheck);
		} catch (e) {
			return this.logError(e);
		}
	}
	//组装系统参数
	sysParams["app_key"] = this.appkey;
	sysParams["v"] = this.apiVersion;
	sysParams["format"] = this.format;
	sysParams["sign_method"] = this.signMethod;
	sysParams["method"] = request.getApiMethodName();
	sysParams["timestamp"] = (function() {
		var time = new Date();
		return time.toISOString().substr(0, 10) + ' ' + time.toLocaleTimeString();
	})();
	// sysParams["partner_id"] = this.sdkVersion;
	if (null != params["session"]) {
		sysParams["session"] = session;
	}
	//获取业务参数
	apiParams = request.getApiParas();
	//签名
	sysParams['sign'] = this.generateSign((function() {
		for (var key in apiParams) {
			allParams[key] = apiParams[key];
		}
		for (var key in sysParams) {
			allParams[key] = sysParams[key];
		}
		return allParams;
	})());
	allParams['sign'] = sysParams['sign'];
	//系统参数放入GET请求串
	this.gatewayPath += '?';
	for (var key in allParams) {
		this.gatewayPath += key + "=" + encodeURIComponent(allParams[key]) + "&";
	}
	this.gatewayPath = this.gatewayPath.substr(0, this.gatewayPath.length - 1);

	// 注册回调事件
	this.emitter.on("called", cb);

	//发起HTTP请求
	try {
		this.request(allParams);
	} catch (e) {
		return this.logError(e);
	}
};
 autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
     var test = require(nodePath.join(dir, 'test.js'));
     test.check(expect, helpers, done);
 });
Example #25
0
module.exports = function (cli, argv, cwd) {
    for (var optionName in options) {
        optimist.options(optionName, options[optionName]);
    }

    argv = optimist.parse(argv);

    var buildName,
        status,
        mixinBuilds = argv._[1],
        sortOrder = argv.sort,
        isDeepAnalytics = argv.deep,
        lmdDir = path.join(cwd, '.lmd');

    if (mixinBuilds) {
        mixinBuilds = mixinBuilds.split('+');

        buildName = mixinBuilds.shift();
    }

    // Clear CLI options
    delete argv.sort;
    delete argv.deep;
    delete argv['order-by'];
    delete argv._;
    delete argv.$0;

    if (!init.check(cli, cwd)) {
        return;
    }

    if (!buildName) {
        printHelp(cli);
        return;
    }

    status = create.checkFile(cwd, buildName);

    if (status !== true) {
        printHelp(cli, status === false ? 'build `' + buildName + '` is not exists' : status);
        return;
    }

    // Check mixins
    if (mixinBuilds.length) {
        var isCanContinue = mixinBuilds.every(function (buildName) {
            status = create.checkFile(cwd, buildName);

            if (status !== true) {
                printHelp(cli, status === false ? 'mixin build `' + buildName + '` is not exists' : status);
                return false;
            }
            return true;
        });

        if (!isCanContinue) {
            return;
        }
    }

    mixinBuilds = mixinBuilds.map(function (mixinName) {
        return resolveName(lmdDir, mixinName);
    });

    if (mixinBuilds.length) {
        argv.mixins = mixinBuilds;
    }

    var buildFile = resolveName(lmdDir, buildName),
        lmdFile = path.join(lmdDir, buildFile);

    var rawConfig = common.readConfig(lmdFile),
        flags = Object.keys(flagToOptionNameMap),
        extraFlags = common.SOURCE_TWEAK_FLAGS,
        config = assembleLmdConfig(lmdFile, flags, argv),
        root = path.resolve(path.join(cwd, '.lmd'), config.root),
        output = config.output ? path.resolve(root, config.output) : 'STDOUT'.yellow,
        styles_output = config.styles_output ? path.resolve(root, config.styles_output) : '/dev/null'.yellow,
        sourcemap = config.sourcemap ? path.resolve(root, config.sourcemap) : false,
        www = config.www_root ? path.resolve(path.join(cwd, '.lmd'), config.www_root) : false,
        versionString = config.version ? ' - version ' + config.version.toString().cyan : '';

    cli.ok('');
    cli.ok('LMD Package `' + buildName.green + '` (' + path.join('.lmd', buildFile).green + ')' + versionString);
    cli.ok('');

    if (rawConfig.extends) {
        cli.ok('Extends LMD Package `' + (rawConfig.extends + '').green + '`');
        cli.ok('');
    }

    if (rawConfig.mixins) {
        cli.ok('Mixins LMD Package `' + (rawConfig.mixins + '').green + '`');
        cli.ok('');
    }

    if (config.name || config.description) {
        config.name && cli.ok(config.name.toString().white.bold);
        if (config.description) {
            // Multiline description
            var descriptionLines = config.description.toString().split('\n');
            descriptionLines.forEach(function (line) {
                cli.ok(line);
            });
        }
        cli.ok('');
    }

    var deepModulesInfo = common.collectModulesInfo(config),
        conflicts = common.getSuspiciousNames(config, deepModulesInfo).conflicts;

    printModules(cli, config, deepModulesInfo, conflicts, sortOrder);
    printModulePathsAndDepends(cli, config, deepModulesInfo, conflicts, isDeepAnalytics);
    printStyles(cli, config);
    printUserPlugins(cli, config);
    printFlags(cli, config, flags.concat(extraFlags));

    cli.ok('Paths'.white.bold.underline);
    cli.ok('');
    cli.ok('root'.cyan + '           ' + printValue(root));
    cli.ok('output'.cyan + '         ' + printValue(output));
    cli.ok('styles_output'.cyan + '  ' + printValue(styles_output));
    cli.ok('www_root'.cyan + '       ' + printValue(www));

    if (sourcemap) {
        cli.ok('');
        cli.ok('Source Map'.white.bold.underline);
        cli.ok('');

        cli.ok('sourcemap'.cyan + '         ' + printValue(sourcemap));
        cli.ok('sourcemap_www'.cyan + '     ' + printValue(config.sourcemap_www || '/'));
        cli.ok('sourcemap_inline'.cyan + '  ' + printValue(config.sourcemap_inline));
        cli.ok('sourcemap_url'.cyan + '     ' + printValue(config.sourcemap_url || '/' + sourcemap.replace(www, '')));
    }

    var errors = config.errors;

    // pipe warnings
    common.iterateModulesInfo(deepModulesInfo, function (info) {
        errors.push.apply(errors, info.warns)
    });

    errors = errors.concat(common.collectFlagsWarnings(config, deepModulesInfo));

    if (errors && errors.length) {
        cli.warn('');
        cli.warn('Warnings'.red.bold.underline);
        cli.warn('');
        errors.forEach(function (error) {
            cli.warn(error);
        });
    }

    common.collectFlagsNotifications(config).forEach(function (notification) {
        cli.ok(notification);
    });

    cli.ok('');
};
Example #26
0
	post(function(req,res){
		UserLogic.check(req.body, function(data){
					operationResultBuilder(data, res);		
		})
	});
Example #27
0
 .then((lassoPageResult) => {
     main.check(lassoPageResult, writerTracker);
     lasso.flushAllCaches(done);
 })
Example #28
0
File: watch.js Project: Aetet/lmd
module.exports = function (cli, argv, cwd) {
    argv = optimist.parse(argv);

    var status,
        buildName,
        mixinBuilds = argv._[1],
        lmdDir = path.join(cwd, '.lmd');

    if (mixinBuilds) {
        mixinBuilds = mixinBuilds.split('+');

        buildName = mixinBuilds.shift();
    }

    delete argv._;
    delete argv.$0;

    if (!init.check(cli, cwd)) {
        return;
    }

    if (!buildName) {
        printHelp(cli);
        return;
    }

    status = create.checkFile(cwd, buildName);

    if (status !== true) {
        printHelp(cli, status === false ? 'build `' + buildName + '` is not exists' : status);
        return;
    }

    // Check mixins
    if (mixinBuilds.length) {
        var isCanContinue = mixinBuilds.every(function (buildName) {
            status = create.checkFile(cwd, buildName);

            if (status !== true) {
                printHelp(cli, status === false ? 'mixin build `' + buildName + '` is not exists' : status);
                return false;
            }
            return true;
        });

        if (!isCanContinue) {
            return;
        }
    }

    mixinBuilds = mixinBuilds.map(function (mixinName) {
        return resolveName(lmdDir, mixinName);
    });

    if (mixinBuilds.length) {
        argv.mixins = mixinBuilds;
    }

    var lmdFile = path.join(lmdDir, resolveName(lmdDir, buildName));

    var watchResult = new lmdPackage.watch(lmdFile, argv),
        watchConfig = watchResult.watchConfig;

    if (watchConfig.log) {
        watchResult.log.pipe(cli.stream);
    }

};
Example #29
0
 autotest.scanDir(autoTestDir, function run(dir, helpers, done) {
     var test = require(nodePath.join(dir, 'test.js'));
     test.check(taglibLoader, expect);
     done();
 });