summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-02-12 20:44:55 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-02-12 20:44:55 +0900
commit03732b66c8992c467ecbbf5d7c4e56536f82cfec (patch)
treec00948866bb4d5836396c41f0e9fe1f598c549f2
parent[Test] Add some drive tests (diff)
downloadsharkey-03732b66c8992c467ecbbf5d7c4e56536f82cfec.tar.gz
sharkey-03732b66c8992c467ecbbf5d7c4e56536f82cfec.tar.bz2
sharkey-03732b66c8992c467ecbbf5d7c4e56536f82cfec.zip
[Test] Add some auth tests
-rw-r--r--test/api.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js
index 70a38e71c6..b0aeec0b1a 100644
--- a/test/api.js
+++ b/test/api.js
@@ -924,6 +924,37 @@ describe('API', () => {
});
}));
});
+
+ describe('auth/session/generate', () => {
+ it('認証セッションを作成できる', () => new Promise(async (done) => {
+ const app = await insertApp();
+ request('/auth/session/generate', {
+ app_secret: app.secret
+ }).then(res => {
+ res.should.have.status(200);
+ res.body.should.be.a('object');
+ res.body.should.have.property('token');
+ res.body.should.have.property('url');
+ done();
+ });
+ }));
+
+ it('app_secret 無しで怒られる', () => new Promise(async (done) => {
+ request('/auth/session/generate', {}).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+
+ it('誤った app secret で怒られる', () => new Promise(async (done) => {
+ request('/auth/session/generate', {
+ app_secret: 'kyoppie'
+ }).then(res => {
+ res.should.have.status(400);
+ done();
+ });
+ }));
+ });
});
async function insertSakurako(opts) {
@@ -955,3 +986,11 @@ async function insertDriveFolder(opts) {
name: 'my folder'
}), opts);
}
+
+async function insertApp(opts) {
+ return await db.get('apps').insert(Object.assign({
+ name: 'my app',
+ secret: 'mysecret'
+ }), opts);
+}
+