Skip to content
Snippets Groups Projects
Commit f76d55b1 authored by syuilo's avatar syuilo
Browse files

[WIP] test

parent 33b6c232
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import recaptcha = require('recaptcha-promise');
import User from '../models/user';
import { validateUsername } from '../models/user';
import serialize from '../serializers/user';
import config from '../../conf';
recaptcha.init({
secret_key: config.recaptcha.secretKey
......@@ -12,11 +13,14 @@ recaptcha.init({
export default async (req: express.Request, res: express.Response) => {
// Verify recaptcha
const success = await recaptcha(req.body['g-recaptcha-response']);
// ただしテスト時はこの機構は障害となるため無効にする
if (process.env.NODE_ENV !== 'test') {
const success = await recaptcha(req.body['g-recaptcha-response']);
if (!success) {
res.status(400).send('recaptcha-failed');
return;
if (!success) {
res.status(400).send('recaptcha-failed');
return;
}
}
const username = req.body['username'];
......
/**
* API TESTS
*/
// During the test the env variable is set to test
process.env.NODE_ENV = 'test';
const chai = require('chai');
const chaiHttp = require('chai-http');
const server = require('../built/server');
const should = chai.should();
chai.use(chaiHttp);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment