mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-06-19 04:35:04 +08:00
移除 API 测试
This commit is contained in:
3
Makefile
3
Makefile
@@ -6,9 +6,6 @@ install:
|
||||
build: install
|
||||
node node_modules/coffee-script/bin/coffee -c .
|
||||
|
||||
test: build
|
||||
bash run-test.bash
|
||||
|
||||
clean:
|
||||
find . -path './node_modules' -prune -o -name '*.js' -exec rm -fr {} \;
|
||||
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
frisby = require 'frisby'
|
||||
|
||||
config = require '../../core/config'
|
||||
|
||||
baseUrl = "http://127.0.0.1:#{config.web.port}"
|
||||
|
||||
frisby.create '/account/signup/'
|
||||
.post "#{baseUrl}/account/signup/",
|
||||
username: 'test'
|
||||
email: 'test@jysperm.me'
|
||||
passwd: 'password'
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/account/signup email_exist'
|
||||
.post "#{baseUrl}/account/signup/",
|
||||
username: 'test2'
|
||||
email: 'test@jysperm.me'
|
||||
passwd: 'password'
|
||||
.expectStatus 400
|
||||
.expectJSON
|
||||
error: 'email_exist'
|
||||
.toss()
|
||||
|
||||
frisby.create '/account/login/'
|
||||
.post "#{baseUrl}/account/login/",
|
||||
username: 'test@jysperm.me',
|
||||
passwd: 'password'
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
token: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/account/login/'
|
||||
.post "#{baseUrl}/account/login/",
|
||||
username: 'test',
|
||||
passwd: 'password'
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
token: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/account/logout/'
|
||||
.post "#{baseUrl}/account/logout/", {},
|
||||
headers:
|
||||
'x-token': 'need_be_remove'
|
||||
.expectStatus 200
|
||||
.toss()
|
||||
|
||||
frisby.create '/account/logout/ auth_failed'
|
||||
.post "#{baseUrl}/account/logout/", {},
|
||||
headers:
|
||||
'x-token': 'token_not_exist'
|
||||
.expectStatus 400
|
||||
.expectJSON
|
||||
error: 'auth_failed'
|
||||
.toss()
|
||||
|
||||
frisby.globalSetup
|
||||
request:
|
||||
headers:
|
||||
'x-token': 'token'
|
||||
|
||||
frisby.create '/account/update_passwd/'
|
||||
.post "#{baseUrl}/account/update_passwd/",
|
||||
old_passwd: 'password',
|
||||
new_passwd: '123123'
|
||||
.expectStatus 200
|
||||
.toss()
|
||||
@@ -1,83 +0,0 @@
|
||||
async = require 'async'
|
||||
|
||||
db = require '../../core/db'
|
||||
|
||||
module.exports = (callback) ->
|
||||
cAccount = db.collection 'accounts'
|
||||
cTicket = db.collection 'tickets'
|
||||
|
||||
async.parallel [
|
||||
(callback) ->
|
||||
cAccount.remove
|
||||
username: $in: ['test', 'test_main']
|
||||
, callback
|
||||
|
||||
(callback) ->
|
||||
cAccount.remove
|
||||
email: 'test@jysperm.me'
|
||||
, callback
|
||||
|
||||
(callback) ->
|
||||
cAccount.insert
|
||||
_id: db.ObjectID '533b0cb894f6c673123e33a3'
|
||||
|
||||
username: 'test_main'
|
||||
passwd: '9de9bb1f01888f4cf6c32cd02c6ad2b15804b292947552324ae8f7d52e12714c'
|
||||
passwd_salt: '9499537d1f65ae43e7ac4d1c2901bb7647ac735b5b9b6c9eea945d8453c3636f'
|
||||
email: 'test_main@jysperm.me'
|
||||
singup_at: new Date()
|
||||
|
||||
group: ['root']
|
||||
setting: {}
|
||||
attribute: {}
|
||||
|
||||
tokens: [
|
||||
{
|
||||
token: 'token'
|
||||
available: true
|
||||
created_at: new Date()
|
||||
updated_at: new Date()
|
||||
|
||||
attribute: {}
|
||||
},
|
||||
{
|
||||
token: 'need_be_remove'
|
||||
available: true
|
||||
created_at: new Date()
|
||||
updated_at: new Date()
|
||||
|
||||
attribute: {}
|
||||
}
|
||||
]
|
||||
, callback
|
||||
|
||||
(callback) ->
|
||||
cTicket.remove
|
||||
account_id: db.ObjectID '533b0cb894f6c673123e33a3'
|
||||
, callback
|
||||
|
||||
(callback) ->
|
||||
cTicket.insert
|
||||
_id: db.ObjectID '533b0cb894f6c673123e33a4'
|
||||
account_id: db.ObjectID '533b0cb894f6c673123e33a3'
|
||||
created_at: new Date()
|
||||
updated_at: new Date()
|
||||
title: 'Ticket Title'
|
||||
content: 'Ticket Content(Markdown)'
|
||||
content_html: 'Ticket Conetnt(HTML)'
|
||||
type: 'linux'
|
||||
status: 'open'
|
||||
members: [
|
||||
db.ObjectID '533b0cb894f6c673123e33a3'
|
||||
]
|
||||
attribute: {}
|
||||
replys: []
|
||||
, callback
|
||||
|
||||
], ->
|
||||
callback()
|
||||
|
||||
unless module.parent
|
||||
db.connect ->
|
||||
module.exports ->
|
||||
process.exit()
|
||||
@@ -1,10 +0,0 @@
|
||||
frisby = require 'frisby'
|
||||
|
||||
config = require '../../core/config'
|
||||
|
||||
baseUrl = "http://127.0.0.1:#{config.web.port}"
|
||||
|
||||
frisby.globalSetup
|
||||
request:
|
||||
headers:
|
||||
'x-token': 'token'
|
||||
@@ -1,79 +0,0 @@
|
||||
frisby = require 'frisby'
|
||||
|
||||
config = require '../../core/config'
|
||||
|
||||
baseUrl = "http://127.0.0.1:#{config.web.port}"
|
||||
|
||||
frisby.globalSetup
|
||||
request:
|
||||
headers:
|
||||
'x-token': 'token'
|
||||
|
||||
frisby.create '/ticket/create/'
|
||||
.post "#{baseUrl}/ticket/create/",
|
||||
title: 'Ticket Title'
|
||||
content: 'Ticket Content(Markdown)'
|
||||
type: 'linux'
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/create/ invalid_type'
|
||||
.post "#{baseUrl}/ticket/create/",
|
||||
title: 'Ticket Title'
|
||||
content: 'Ticket Content(Markdown)'
|
||||
type: 'type_not_exist'
|
||||
.expectStatus 400
|
||||
.expectJSON
|
||||
error: 'invalid_type'
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/create/'
|
||||
.post "#{baseUrl}/ticket/create/",
|
||||
title: 'Ticket Title'
|
||||
content: 'Ticket Content(Markdown)'
|
||||
type: 'linux'
|
||||
members: ['test']
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/reply/'
|
||||
.post "#{baseUrl}/ticket/reply/",
|
||||
id: '533b0cb894f6c673123e33a4'
|
||||
content: 'Reply Content(Markdown)'
|
||||
.expectStatus 200
|
||||
.expectJSONTypes
|
||||
id: String
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/update/'
|
||||
.post "#{baseUrl}/ticket/update/",
|
||||
id: '533b0cb894f6c673123e33a4'
|
||||
type: 'nodejs'
|
||||
status: 'closed'
|
||||
.expectStatus 200
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/update/'
|
||||
.post "#{baseUrl}/ticket/update/",
|
||||
id: '533b0cb894f6c673123e33a4'
|
||||
attribute:
|
||||
public: true
|
||||
.expectStatus 200
|
||||
.toss()
|
||||
|
||||
frisby.create '/ticket/list/'
|
||||
.post "#{baseUrl}/ticket/list/",
|
||||
status: 'open'
|
||||
.expectStatus 200
|
||||
.expectJSON '*',
|
||||
status: 'open'
|
||||
.expectJSONTypes '*',
|
||||
id: String
|
||||
title: String
|
||||
type: String
|
||||
updated_at: String
|
||||
.toss()
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
node node_modules/coffee-script/bin/coffee app.coffee &
|
||||
sleep 1s
|
||||
SERVER_PID="$!"
|
||||
node node_modules/coffee-script/bin/coffee TEST/API/init.coffee
|
||||
node node_modules/jasmine-node/bin/jasmine-node --junitreport TEST/API
|
||||
kill "$SERVER_PID"
|
||||
Reference in New Issue
Block a user