fix rate-limiting tests

Mojang is now rate-limiting calls to their sessionserver case-insensitive.

This fix skips network-based tests for an upper-cased UUID which are previously
run with the same lower-cased UUID
This commit is contained in:
jomo 2016-11-03 21:51:43 +01:00
parent f0b73b34d1
commit f7b8fd4e8c

View File

@ -933,13 +933,15 @@ describe("Crafatar", function() {
var iid = ids[i];
var iid_type = iid.length > 16 ? "uuid" : "name";
// needs an anonymous function because id and id_type aren't constant
(function(id, id_type) {
(function(n, id, id_type) {
// Mojang's UUID rate limiting is case-insensitive
// so we don't run UUID tests twice
if(n < 3) {
describe("Networking: Avatar", function() {
before(function() {
cache.get_redis().flushall();
console.log("\n\nRunning tests with " + id_type + " '" + id + "'\n\n");
});
it("should be downloaded", function(done) {
helpers.get_avatar(rid(), id, false, 160, function(err, status, image) {
assert.ifError(err);
@ -1002,15 +1004,21 @@ describe("Crafatar", function() {
});
});
});
}
describe("Errors", function() {
before(function() {
if(n >= 3) {
// Notice for tests skipped above
console.log("\n\nSkipping tests with " + id_type + " '" + id + "' due to case-insensitive rate-limiting\n\n");
}
cache.get_redis().flushall();
});
if (id_type === "uuid") {
it("uuid should be rate limited", function(done) {
// just making sure ...
it("uuid SHOULD be rate limited", function(done) {
networking.get_profile(rid(), id, function() {
networking.get_profile(rid(), id, function(err, profile) {
assert.strictEqual(err.toString(), "HTTP: 429");
@ -1030,6 +1038,6 @@ describe("Crafatar", function() {
});
}
});
}(iid, iid_type));
}(i, iid, iid_type));
}
});