test passing: get kicked for no credentials in online mode

This commit is contained in:
Andrew Kelley 2013-01-02 02:33:40 -05:00
parent 73e274e5c9
commit 46d862b1c4
2 changed files with 26 additions and 5 deletions

View File

@ -11,8 +11,12 @@ Parse and serialize minecraft packets, plus authentication and encryption.
- Supports encryption - Supports encryption
- Supports online mode - Supports online mode
- Supports offline mode - Supports offline mode
* Send keep-alive packet at the correct interval. * Respond to keep-alive packets.
* Reasonable amount of test coverage (TODO #3) * Test coverage
- encryption
- authentication/online mode
- offline mode
- initialization packets
* Optimized for rapidly staying up to date with Minecraft protocol updates. * Optimized for rapidly staying up to date with Minecraft protocol updates.
## Minecraft Compatibility ## Minecraft Compatibility

View File

@ -85,10 +85,10 @@ describe("minecraft protocol", function() {
} }
mcServer.on('line', onLine); mcServer.on('line', onLine);
mcServer.on('line', function(line) { mcServer.on('line', function(line) {
process.stderr.write('.'); //process.stderr.write('.');
// uncomment this line when debugging for more insight as to what is // uncomment this line when debugging for more insight as to what is
// happening on the minecraft server // happening on the minecraft server
//console.error("[MC]", line); console.error("[MC]", line);
}); });
function onLine(line) { function onLine(line) {
if (/\[INFO\] Done/.test(line)) { if (/\[INFO\] Done/.test(line)) {
@ -180,6 +180,23 @@ describe("minecraft protocol", function() {
}); });
}); });
}); });
it("emits error when no credentials supplied in online mode"); it("gets kicked when no credentials supplied in online mode", function(done) {
startServer({ 'online-mode': 'true' }, function() {
var client = mc.createClient({
username: process.env.MC_USERNAME,
});
var gotKicked = false;
client.on('packet', function(packet) {
if (packet.id === 0xff) {
assert.strictEqual(packet.reason, "Failed to verify username!");
gotKicked = true;
}
});
client.on('end', function() {
assert.ok(gotKicked);
done();
});
});
});
it("survives for " + SURVIVE_TIME + "ms"); it("survives for " + SURVIVE_TIME + "ms");
}); });