|
@@ -31,10 +31,10 @@ function getRandomInt(min, max) {
|
|
|
}
|
|
|
|
|
|
var ids = [
|
|
|
-uuid.toLowerCase(),
|
|
|
-name.toLowerCase(),
|
|
|
-name.toUpperCase(),
|
|
|
-uuid.toUpperCase(),
|
|
|
+ uuid.toLowerCase(),
|
|
|
+ name.toLowerCase(),
|
|
|
+ name.toUpperCase(),
|
|
|
+ uuid.toUpperCase(),
|
|
|
];
|
|
|
|
|
|
describe("Crafatar", function() {
|
|
@@ -45,8 +45,8 @@ describe("Crafatar", function() {
|
|
|
cache.get_redis().flushall();
|
|
|
// largest possible integers, cause I don't know
|
|
|
// how big hard drives are these days
|
|
|
- config.cleaning_disk_limit = Math.pow(2,32) - 1;;
|
|
|
- config.cleaning_redis_limit = Math.pow(2,32) - 1;;
|
|
|
+ config.cleaning_disk_limit = Math.pow(2, 32) - 1;;
|
|
|
+ config.cleaning_redis_limit = Math.pow(2, 32) - 1;;
|
|
|
cleaner.run();
|
|
|
});
|
|
|
|
|
@@ -105,7 +105,7 @@ describe("Crafatar", function() {
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
-describe("Avatar", function() {
|
|
|
+ describe("Avatar", function() {
|
|
|
// profile "Alex" - hoping it'll never have a skin
|
|
|
var alex_uuid = "ec561538f3fd461daff5086b22154bce";
|
|
|
// profile "Steven" (Steve doesn't exist) - hoping it'll never have a skin
|
|
@@ -129,66 +129,62 @@ describe("Avatar", function() {
|
|
|
done();
|
|
|
});
|
|
|
});
|
|
|
-describe("Errors", function() {
|
|
|
- it("should time out on uuid info download", function(done) {
|
|
|
- var original_timeout = config.http_timeout;
|
|
|
- config.http_timeout = 1;
|
|
|
- networking.get_profile(rid, "069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
|
|
- assert.strictEqual(err.code, "ETIMEDOUT");
|
|
|
- config.http_timeout = original_timeout;
|
|
|
- done();
|
|
|
+ describe("Errors", function() {
|
|
|
+ it("should time out on uuid info download", function(done) {
|
|
|
+ var original_timeout = config.http_timeout;
|
|
|
+ config.http_timeout = 1;
|
|
|
+ networking.get_profile(rid, "069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
|
|
+ assert.strictEqual(err.code, "ETIMEDOUT");
|
|
|
+ config.http_timeout = original_timeout;
|
|
|
+ done();
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- it("should time out on username info download", function(done) {
|
|
|
- var original_timeout = config.http_timeout;
|
|
|
- config.http_timeout = 1;
|
|
|
- networking.get_username_url(rid, "jomo", 0, function(err, url) {
|
|
|
- assert.strictEqual(err.code, "ETIMEDOUT");
|
|
|
- config.http_timeout = original_timeout;
|
|
|
- done();
|
|
|
+ it("should time out on username info download", function(done) {
|
|
|
+ var original_timeout = config.http_timeout;
|
|
|
+ config.http_timeout = 1;
|
|
|
+ networking.get_username_url(rid, "jomo", 0, function(err, url) {
|
|
|
+ assert.strictEqual(err.code, "ETIMEDOUT");
|
|
|
+ config.http_timeout = original_timeout;
|
|
|
+ done();
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- it("should time out on skin download", function(done) {
|
|
|
- var original_timeout = config.http_timeout;
|
|
|
- config.http_timeout = 1;
|
|
|
- networking.get_from(rid, "http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) {
|
|
|
- assert.strictEqual(error.code, "ETIMEDOUT");
|
|
|
- config.http_timeout = original_timeout;
|
|
|
- done();
|
|
|
+ it("should time out on skin download", function(done) {
|
|
|
+ var original_timeout = config.http_timeout;
|
|
|
+ config.http_timeout = 1;
|
|
|
+ networking.get_from(rid, "http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) {
|
|
|
+ assert.strictEqual(error.code, "ETIMEDOUT");
|
|
|
+ config.http_timeout = original_timeout;
|
|
|
+ done();
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- it("should not find the skin", function(done) {
|
|
|
- assert.doesNotThrow(function() {
|
|
|
- networking.get_from(rid, "http://textures.minecraft.net/texture/this-does-not-exist", function(img, response, err) {
|
|
|
+ it("should not find the skin", function(done) {
|
|
|
+ assert.doesNotThrow(function() {
|
|
|
+ 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
|
|
|
done();
|
|
|
});
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- it("should ignore file updates on invalid files", function(done) {
|
|
|
- assert.doesNotThrow(function() {
|
|
|
- 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);
|
|
|
+ it("should ignore file updates on invalid files", function(done) {
|
|
|
+ assert.doesNotThrow(function() {
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
-});
|
|
|
-
|
|
|
-describe("Cleaner", function() {
|
|
|
-
|
|
|
-});
|
|
|
|
|
|
-describe("Server", function() {
|
|
|
- before(function(done) {
|
|
|
- server.boot(function() {
|
|
|
- done();
|
|
|
+ describe("Server", function() {
|
|
|
+ before(function(done) {
|
|
|
+ server.boot(function() {
|
|
|
+ done();
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
|
|
|
// Test the home page
|
|
|
it("should return a 200 (home page)", function(done) {
|
|
@@ -403,61 +399,61 @@ describe("Server", function() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-describe("Networking: Skin", function() {
|
|
|
- it("should not fail (uuid)", function(done) {
|
|
|
- helpers.get_skin(rid, id, function(err, hash, img) {
|
|
|
- assert.strictEqual(err, null);
|
|
|
- done();
|
|
|
- });
|
|
|
- });
|
|
|
-});
|
|
|
+ describe("Networking: Skin", function() {
|
|
|
+ it("should not fail (uuid)", function(done) {
|
|
|
+ helpers.get_skin(rid, id, function(err, hash, img) {
|
|
|
+ assert.strictEqual(err, null);
|
|
|
+ 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: 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("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();
|
|
|
- });
|
|
|
+ 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();
|
|
|
+ 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);
|
|
|
-}
|
|
|
});
|