Fallback tests are added

This commit is contained in:
András Rutkai committed 2016-08-12 23:40:46 +02:00
1 parent 8508284069
commit a1d3cd5ce2
5 files changed
+190 -4

No files matched your search

+10 -1
View File
@@ -21,4 +21,13 @@ after_script:
- process.exit()
env:
- NODE_ENV=testing-config
- NODE_ENV=testing-mongodb
- NODE_ENV=testing-mongodb
- NODE_ENV=testing-fallback
matrix:
exclude:
- node_js: '6'
env: NODE_ENV=testing-fallback
- node_js: '5'
env: NODE_ENV=testing-fallback
- node_js: '0.12'
env: NODE_ENV=testing-fallback
+12 -3
View File
@@ -15,13 +15,22 @@ Note: Underscore is required because of an issue in the dependencies of mongodb-
First, start the server in testing mode:
NODE_ENV=testing node app.js
NODE_ENV=testing-config node app.js
(Re)populate the testing Mongodb database:
mongo test --eval \"db.dropDatabase()\"
mongofixtures test fixtures
Then the tests:
NODE_ENV=testing jasmine-node test
NODE_ENV=testing-config jasmine-node test
All tests must pass.
All tests must pass. You have to repeat the steps above for all environments:
* testing-config
* testing-mongodb
* testing-fallback
## Misc dev notes
+39
View File
@@ -0,0 +1,39 @@
{
"serverOwner": "Tester",
"timestampFormat": "YYYY-MM-DD HH:mm:ss| ",
"hashAlgorithm": "md5",
"secret": "test-token",
"authserver": {
"httpPort": 6666,
"httpsPort": 6667
},
"sessionserver": {
"httpPort": 6677,
"httpsPort": 6678
},
"apiserver": {
"httpPort": 6688,
"httpsPort": 6689
},
"users": [
{
"id": "650bed2c-9ef5-4b5f-b02c-61fa493c68b5",
"username": "test",
"password": "098f6bcd4621d373cade4e832627b4f6", // test using MD5
"playerName": "testPlayer",
"skinUrl": "steve.png"
},
{
"id": "0e565137-f983-49fe-ac61-15adfe19e962",
"username": "overlapUser",
"password": "912ec803b2ce49e4a541068d495ab570", // asdf using MD5
"playerName": "overlapPlayer",
"playerNameIndex": "overlapplayer",
"skinUrl": "steve.png"
}
],
"drivers": ["config", "mongodb"],
"mongodb": {
"connectionStr": "mongodb://localhost:27017/test"
}
}
+16
View File
@@ -18,5 +18,21 @@ exports.user = [
"clientToken": "test-old-client-token",
"accessToken": "d41d8cd98f00b204e9800998ecf8427e",
"lastLogin": "2015-04-23T18:25:43.511Z"
},
{
"id": "9a7f1d46-4050-462e-bb32-fe4d78f7ec03",
"username": "overlapUser",
"password": "098f6bcd4621d373cade4e832627b4f6",
"playerName": "overlapPlayer",
"playerNameIndex": "overlapplayer",
"skinUrl": "steve.png"
},
{
"id": "7ac4a66d-859d-4691-a2da-be490d0badcb",
"username": "dbUser",
"password": "d77d5e503ad1439f585ac494268b351b", // db using MD5
"playerName": "dbPlayer",
"playerNameIndex": "dbplayer",
"skinUrl": "steve.png"
}
];
+113
View File
@@ -0,0 +1,113 @@
var frisby = require('frisby');
var config = require('config');
var httpPort = config.get('authserver.httpPort');
if (config.get('drivers').length !== 2) {
return;
}
frisby.create('Missing user gives authentication error')
.post('http://localhost:' + httpPort + '/authenticate', {
"username": "nonexistent",
"password": "asdf"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSON({
"error": "ForbiddenOperationException",
"errorMessage": "Invalid credentials. Invalid username or password."
})
.expectJSONTypes({
"error": String,
"errorMessage": String
})
.toss();
frisby.create('Wrong password for config user gives authentication error')
.post('http://localhost:' + httpPort + '/authenticate', {
"username": "test",
"password": "asdf"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSON({
"error": "ForbiddenOperationException",
"errorMessage": "Invalid credentials. Invalid username or password."
})
.expectJSONTypes({
"error": String,
"errorMessage": String
})
.toss();
frisby.create('Valid credentials in config user')
.post('http://localhost:' + httpPort + '/authenticate', {
"username": "test",
"password": "test"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSONTypes({
"accessToken": String,
"clientToken": String
})
.toss();
frisby.create('Wrong password in mongodb user')
.post('http://localhost:' + httpPort + '/authenticate', {
"username": "dbUser",
"password": "test"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSON({
"error": "ForbiddenOperationException",
"errorMessage": "Invalid credentials. Invalid username or password."
})
.expectJSONTypes({
"error": String,
"errorMessage": String
})
.toss();
frisby.create('Valid credentials using mongodb user')
.post('http://localhost:' + httpPort + '/authenticate', {
"username": "dbUser",
"password": "db"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSONTypes({
"accessToken": String,
"clientToken": String
})
.toss();
frisby.create('Config user overlaps mongodb user')
.post('http://localhost:' + httpPort + '/authenticate', {
"agent": {
"name": "Minecraft",
"version": 1
},
"username": "overlapUser",
"password": "asdf"
})
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSON({
"availableProfiles": [
{
"id": "0e565137f98349feac6115adfe19e962",
"name": "overlapPlayer"
}
],
"selectedProfile": {
"id": "0e565137f98349feac6115adfe19e962",
"name": "overlapPlayer"
}
})
.expectJSONTypes({
"accessToken": String,
"clientToken": String
})
.toss();