mirror of
https://github.com/azures04/crafatar.git
synced 2026-05-06 11:00:39 +02:00
prepend request IDs instead of UUIDs, fixes #77
also cleaned up a few other things I noticed when looking over the files
This commit is contained in:
40
test/test.js
40
test/test.js
@@ -86,7 +86,7 @@ describe("Crafatar", function() {
|
||||
});
|
||||
it("should not exist (uuid)", function(done) {
|
||||
var number = getRandomInt(0, 9).toString();
|
||||
networking.get_profile(Array(33).join(number), function(err, profile) {
|
||||
networking.get_profile("testreq", Array(33).join(number), function(err, profile) {
|
||||
assert.strictEqual(profile, null);
|
||||
done();
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe("Crafatar", function() {
|
||||
var steven_uuid = "b8ffc3d37dbf48278f69475f6690aabd";
|
||||
|
||||
it("uuid's account should exist, but skin should not", function(done) {
|
||||
networking.get_profile(alex_uuid, function(err, profile) {
|
||||
networking.get_profile("testreq", alex_uuid, function(err, profile) {
|
||||
assert.notStrictEqual(profile, null);
|
||||
networking.get_uuid_url(profile, 1, function(url) {
|
||||
assert.strictEqual(url, null);
|
||||
@@ -127,7 +127,7 @@ describe("Crafatar", function() {
|
||||
it("should time out on uuid info download", function(done) {
|
||||
var original_timeout = config.http_timeout;
|
||||
config.http_timeout = 1;
|
||||
networking.get_profile("069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
||||
networking.get_profile("testreq", "069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
||||
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||
config.http_timeout = original_timeout;
|
||||
done();
|
||||
@@ -161,7 +161,7 @@ describe("Crafatar", function() {
|
||||
});
|
||||
it("should ignore file updates on invalid files", function(done) {
|
||||
assert.doesNotThrow(function() {
|
||||
cache.update_timestamp("0123456789abcdef0123456789abcdef", "invalid-file.png");
|
||||
cache.update_timestamp("testreq", "0123456789abcdef0123456789abcdef", "invalid-file.png");
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -176,13 +176,13 @@ describe("Crafatar", function() {
|
||||
// we have to make sure that we test both a 32x64 and 64x64 skin
|
||||
describe("Networking: Render", function() {
|
||||
it("should not fail (username, 32x64 skin)", function(done) {
|
||||
helpers.get_render("md_5", 6, true, true, function(err, hash, img) {
|
||||
helpers.get_render("testreq", "md_5", 6, true, true, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should not fail (username, 64x64 skin)", function(done) {
|
||||
helpers.get_render("Jake0oo0", 6, true, true, function(err, hash, img) {
|
||||
helpers.get_render("testreq", "Jake0oo0", 6, true, true, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -191,7 +191,7 @@ describe("Crafatar", function() {
|
||||
|
||||
describe("Networking: Cape", function() {
|
||||
it("should not fail (guaranteed cape)", function(done) {
|
||||
helpers.get_cape("Dinnerbone", function(err, hash, img) {
|
||||
helpers.get_cape("testreq", "Dinnerbone", function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -200,13 +200,13 @@ describe("Crafatar", function() {
|
||||
before(function() {
|
||||
cache.get_redis().flushall();
|
||||
});
|
||||
helpers.get_cape("Dinnerbone", function(err, hash, img) {
|
||||
helpers.get_cape("testreq", "Dinnerbone", function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should not be found", function(done) {
|
||||
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||
helpers.get_cape("testreq", "Jake0oo0", function(err, hash, img) {
|
||||
assert.strictEqual(img, null);
|
||||
done();
|
||||
});
|
||||
@@ -215,7 +215,7 @@ describe("Crafatar", function() {
|
||||
|
||||
describe("Networking: Skin", function() {
|
||||
it("should not fail", function(done) {
|
||||
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||
helpers.get_cape("testreq", "Jake0oo0", function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -224,7 +224,7 @@ describe("Crafatar", function() {
|
||||
before(function() {
|
||||
cache.get_redis().flushall();
|
||||
});
|
||||
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||
helpers.get_cape("testreq", "Jake0oo0", function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -245,13 +245,13 @@ describe("Crafatar", function() {
|
||||
});
|
||||
|
||||
it("should be downloaded", function(done) {
|
||||
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
||||
helpers.get_avatar("testreq", id, false, 160, function(err, status, image) {
|
||||
assert.strictEqual(status, 2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should be cached", function(done) {
|
||||
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
||||
helpers.get_avatar("testreq", id, false, 160, function(err, status, image) {
|
||||
assert.strictEqual(status === 0 || status === 1, true);
|
||||
done();
|
||||
});
|
||||
@@ -262,7 +262,7 @@ describe("Crafatar", function() {
|
||||
it("should be checked", function(done) {
|
||||
var original_cache_time = config.local_cache_time;
|
||||
config.local_cache_time = 0;
|
||||
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
||||
helpers.get_avatar("testreq", id, false, 160, function(err, status, image) {
|
||||
assert.strictEqual(status, 3);
|
||||
config.local_cache_time = original_cache_time;
|
||||
done();
|
||||
@@ -273,7 +273,7 @@ describe("Crafatar", function() {
|
||||
|
||||
describe("Networking: Skin", function() {
|
||||
it("should not fail (uuid)", function(done) {
|
||||
helpers.get_skin(id, function(err, hash, img) {
|
||||
helpers.get_skin("testreq", id, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -282,13 +282,13 @@ describe("Crafatar", function() {
|
||||
|
||||
describe("Networking: Render", function() {
|
||||
it("should not fail (full body)", function(done) {
|
||||
helpers.get_render(id, 6, true, true, function(err, hash, img) {
|
||||
helpers.get_render("testreq", id, 6, true, true, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should not fail (only head)", function(done) {
|
||||
helpers.get_render(id, 6, true, false, function(err, hash, img) {
|
||||
helpers.get_render("testreq", id, 6, true, false, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -297,7 +297,7 @@ describe("Crafatar", function() {
|
||||
|
||||
describe("Networking: Cape", function() {
|
||||
it("should not fail (possible cape)", function(done) {
|
||||
helpers.get_cape(id, function(err, hash, img) {
|
||||
helpers.get_cape("testreq", id, function(err, hash, img) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
@@ -312,14 +312,14 @@ describe("Crafatar", function() {
|
||||
|
||||
if (id_type == "uuid") {
|
||||
it("uuid should be rate limited", function(done) {
|
||||
networking.get_profile(id, function(err, profile) {
|
||||
networking.get_profile("testreq", id, function(err, profile) {
|
||||
assert.strictEqual(profile.error, "TooManyRequestsException");
|
||||
done();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
it("username should NOT be rate limited (username)", function(done) {
|
||||
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
||||
helpers.get_avatar("testreq", id, false, 160, function(err, status, image) {
|
||||
assert.strictEqual(err, null);
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user