mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
Why does only one test seem to be processed
This commit is contained in:
parent
2c1173b8a5
commit
5a06e99643
@ -45,8 +45,12 @@ module.exports = function(req, res) {
|
|||||||
userId = userId.replace(/-/g, "");
|
userId = userId.replace(/-/g, "");
|
||||||
logging.log(rid + "userid: " + userId);
|
logging.log(rid + "userid: " + userId);
|
||||||
|
|
||||||
|
console.log("THIS WAS CALLED")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log("TRIED")
|
||||||
helpers.get_avatar(rid, userId, helm, size, function(err, status, image, hash) {
|
helpers.get_avatar(rid, userId, helm, size, function(err, status, image, hash) {
|
||||||
|
console.log("I DID RUN COVERALLS!!")
|
||||||
logging.log(rid + "storage type: " + human_status[status]);
|
logging.log(rid + "storage type: " + human_status[status]);
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error(rid + err);
|
logging.error(rid + err);
|
||||||
@ -72,6 +76,7 @@ module.exports = function(req, res) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
console.log("FAILED")
|
||||||
logging.error(rid + "error: " + e.stack);
|
logging.error(rid + "error: " + e.stack);
|
||||||
handle_default(rid, 500, -1, userId);
|
handle_default(rid, 500, -1, userId);
|
||||||
}
|
}
|
||||||
|
|||||||
219
test/test.js
219
test/test.js
@ -1,6 +1,5 @@
|
|||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var networking = require("../modules/networking");
|
var networking = require("../modules/networking");
|
||||||
var helpers = require("../modules/helpers");
|
var helpers = require("../modules/helpers");
|
||||||
var logging = require("../modules/logging");
|
var logging = require("../modules/logging");
|
||||||
@ -32,10 +31,10 @@ function getRandomInt(min, max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ids = [
|
var ids = [
|
||||||
uuid.toLowerCase(),
|
uuid.toLowerCase(),
|
||||||
name.toLowerCase(),
|
name.toLowerCase(),
|
||||||
uuid.toUpperCase(),
|
name.toUpperCase(),
|
||||||
name.toUpperCase(),
|
uuid.toUpperCase(),
|
||||||
];
|
];
|
||||||
|
|
||||||
describe("Crafatar", function() {
|
describe("Crafatar", function() {
|
||||||
@ -102,7 +101,7 @@ describe("Crafatar", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("Avatar", function() {
|
describe("Avatar", function() {
|
||||||
// profile "Alex" - hoping it'll never have a skin
|
// profile "Alex" - hoping it'll never have a skin
|
||||||
var alex_uuid = "ec561538f3fd461daff5086b22154bce";
|
var alex_uuid = "ec561538f3fd461daff5086b22154bce";
|
||||||
// profile "Steven" (Steve doesn't exist) - hoping it'll never have a skin
|
// profile "Steven" (Steve doesn't exist) - hoping it'll never have a skin
|
||||||
@ -126,62 +125,62 @@ describe("Avatar", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("Errors", function() {
|
describe("Errors", function() {
|
||||||
it("should time out on uuid info download", function(done) {
|
it("should time out on uuid info download", function(done) {
|
||||||
var original_timeout = config.http_timeout;
|
var original_timeout = config.http_timeout;
|
||||||
config.http_timeout = 1;
|
config.http_timeout = 1;
|
||||||
networking.get_profile(rid, "069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
networking.get_profile(rid, "069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
||||||
assert.strictEqual(err.code, "ETIMEDOUT");
|
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||||
config.http_timeout = original_timeout;
|
config.http_timeout = original_timeout;
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
it("should time out on username info download", function(done) {
|
||||||
it("should time out on username info download", function(done) {
|
var original_timeout = config.http_timeout;
|
||||||
var original_timeout = config.http_timeout;
|
config.http_timeout = 1;
|
||||||
config.http_timeout = 1;
|
networking.get_username_url(rid, "jomo", 0, function(err, url) {
|
||||||
networking.get_username_url(rid, "jomo", 0, function(err, url) {
|
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||||
assert.strictEqual(err.code, "ETIMEDOUT");
|
config.http_timeout = original_timeout;
|
||||||
config.http_timeout = original_timeout;
|
done();
|
||||||
done();
|
});
|
||||||
});
|
});
|
||||||
});
|
it("should time out on skin download", function(done) {
|
||||||
it("should time out on skin download", function(done) {
|
var original_timeout = config.http_timeout;
|
||||||
var original_timeout = config.http_timeout;
|
config.http_timeout = 1;
|
||||||
config.http_timeout = 1;
|
networking.get_from(rid, "http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) {
|
||||||
networking.get_from(rid, "http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) {
|
assert.strictEqual(error.code, "ETIMEDOUT");
|
||||||
assert.strictEqual(error.code, "ETIMEDOUT");
|
config.http_timeout = original_timeout;
|
||||||
config.http_timeout = original_timeout;
|
done();
|
||||||
done();
|
});
|
||||||
});
|
});
|
||||||
});
|
it("should not find the skin", function(done) {
|
||||||
it("should not find the skin", function(done) {
|
assert.doesNotThrow(function() {
|
||||||
assert.doesNotThrow(function() {
|
networking.get_from(rid, "http://textures.minecraft.net/texture/this-does-not-exist", function(img, response, err) {
|
||||||
networking.get_from(rid, "http://textures.minecraft.net/texture/this-does-not-exist", function(img, response, err) {
|
|
||||||
assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions
|
assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
it("should ignore file updates on invalid files", function(done) {
|
||||||
it("should ignore file updates on invalid files", function(done) {
|
assert.doesNotThrow(function() {
|
||||||
assert.doesNotThrow(function() {
|
cache.update_timestamp(rid, "0123456789abcdef0123456789abcdef", "invalid-file.png");
|
||||||
cache.update_timestamp(rid, "0123456789abcdef0123456789abcdef", "invalid-file.png");
|
});
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
it("should not find the file", function(done) {
|
|
||||||
skins.open_skin(rid, "non/existant/path", function(err, img) {
|
|
||||||
assert.notStrictEqual(err, null);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
it("should not find the file", function(done) {
|
||||||
|
skins.open_skin(rid, "non/existant/path", function(err, img) {
|
||||||
|
assert.notStrictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Server", function() {
|
describe("Server", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
server.boot(function() {
|
server.boot(function() {
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Test the home page
|
// Test the home page
|
||||||
it("should return a 200 (home page)", function(done) {
|
it("should return a 200 (home page)", function(done) {
|
||||||
@ -241,6 +240,12 @@ describe("Server", function() {
|
|||||||
var locations = ["avatars", "capes", "skins", "renders/head"]
|
var locations = ["avatars", "capes", "skins", "renders/head"]
|
||||||
for (var l in locations) {
|
for (var l in locations) {
|
||||||
var location = locations[l];
|
var location = locations[l];
|
||||||
|
it("should return a 200 (valid input " + location + ")", function(done) {
|
||||||
|
request.get("http://localhost:3000/" + location + "/Jake0oo0", function(error, res, body) {
|
||||||
|
assert.equal(200, res.statusCode);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
it("should return a 422 (invalid id " + location + ")", function(done) {
|
it("should return a 422 (invalid id " + location + ")", function(done) {
|
||||||
request.get("http://localhost:3000/" + location + "/thisisaninvaliduuid", function(error, res, body) {
|
request.get("http://localhost:3000/" + location + "/thisisaninvaliduuid", function(error, res, body) {
|
||||||
assert.equal(422, res.statusCode);
|
assert.equal(422, res.statusCode);
|
||||||
@ -248,12 +253,6 @@ describe("Server", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a 200 (valid input " + location + ")", function(done) {
|
|
||||||
request.get("http://localhost:3000/" + location + "/Jake0oo0", function(error, res, body) {
|
|
||||||
assert.equal(200, res.statusCode);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// testing all paths for default images
|
// testing all paths for default images
|
||||||
@ -380,61 +379,61 @@ describe("Server", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Networking: Skin", function() {
|
describe("Networking: Skin", function() {
|
||||||
it("should not fail (uuid)", function(done) {
|
it("should not fail (uuid)", function(done) {
|
||||||
helpers.get_skin(rid, id, function(err, hash, img) {
|
helpers.get_skin(rid, id, function(err, hash, img) {
|
||||||
assert.strictEqual(err, null);
|
assert.strictEqual(err, null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("Networking: Render", function() {
|
|
||||||
it("should not fail (full body)", function(done) {
|
|
||||||
helpers.get_render(rid, id, 6, true, true, function(err, hash, img) {
|
|
||||||
assert.strictEqual(err, null);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should not fail (only head)", function(done) {
|
|
||||||
helpers.get_render(rid, id, 6, true, false, function(err, hash, img) {
|
|
||||||
assert.strictEqual(err, null);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Networking: Cape", function() {
|
|
||||||
it("should not fail (possible cape)", function(done) {
|
|
||||||
helpers.get_cape(rid, id, function(err, hash, img) {
|
|
||||||
assert.strictEqual(err, null);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe("Errors", function() {
|
|
||||||
before(function() {
|
|
||||||
cache.get_redis().flushall();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (id_type == "uuid") {
|
|
||||||
it("uuid should be rate limited", function(done) {
|
|
||||||
networking.get_profile(rid, id, function(err, profile) {
|
|
||||||
assert.strictEqual(profile.error, "TooManyRequestsException");
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
describe("Networking: Render", function() {
|
||||||
it("username should NOT be rate limited (username)", function(done) {
|
it("should not fail (full body)", function(done) {
|
||||||
helpers.get_avatar(rid, id, false, 160, function(err, status, image) {
|
helpers.get_render(rid, id, 6, true, true, function(err, hash, img) {
|
||||||
assert.strictEqual(err, null);
|
assert.strictEqual(err, null);
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should not fail (only head)", function(done) {
|
||||||
|
helpers.get_render(rid, id, 6, true, false, function(err, hash, img) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
describe("Networking: Cape", function() {
|
||||||
|
it("should not fail (possible cape)", function(done) {
|
||||||
|
helpers.get_cape(rid, id, function(err, hash, img) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("Errors", function() {
|
||||||
|
before(function() {
|
||||||
|
cache.get_redis().flushall();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (id_type == "uuid") {
|
||||||
|
it("uuid should be rate limited", function(done) {
|
||||||
|
networking.get_profile(rid, id, function(err, profile) {
|
||||||
|
assert.strictEqual(profile.error, "TooManyRequestsException");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
it("username should NOT be rate limited (username)", function(done) {
|
||||||
|
helpers.get_avatar(rid, id, false, 160, function(err, status, image) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(id, id_type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(id, id_type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Loading…
x
Reference in New Issue
Block a user