• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mysqljs / mysql / 3954445999

pending completion
3954445999

push

github

Douglas Christopher Wilson
build: ubuntu@20.04

869 of 1014 branches covered (85.7%)

5111 of 5264 relevant lines covered (97.09%)

687.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.75
/lib/protocol/packets/ClientAuthenticationPacket.js
1
var Buffer = require('safe-buffer').Buffer;
396✔
2

3
module.exports = ClientAuthenticationPacket;
396✔
4
function ClientAuthenticationPacket(options) {
5
  options = options || {};
656!
6

7
  this.clientFlags   = options.clientFlags;
656✔
8
  this.maxPacketSize = options.maxPacketSize;
656✔
9
  this.charsetNumber = options.charsetNumber;
656✔
10
  this.filler        = undefined;
656✔
11
  this.user          = options.user;
656✔
12
  this.scrambleBuff  = options.scrambleBuff;
656✔
13
  this.database      = options.database;
656✔
14
  this.protocol41    = options.protocol41;
656✔
15
}
16

17
ClientAuthenticationPacket.prototype.parse = function(parser) {
396✔
18
  if (this.protocol41) {
290!
19
    this.clientFlags   = parser.parseUnsignedNumber(4);
290✔
20
    this.maxPacketSize = parser.parseUnsignedNumber(4);
290✔
21
    this.charsetNumber = parser.parseUnsignedNumber(1);
290✔
22
    this.filler        = parser.parseFiller(23);
290✔
23
    this.user          = parser.parseNullTerminatedString();
290✔
24
    this.scrambleBuff  = parser.parseLengthCodedBuffer();
290✔
25
    this.database      = parser.parseNullTerminatedString();
290✔
26
  } else {
27
    this.clientFlags   = parser.parseUnsignedNumber(2);
×
28
    this.maxPacketSize = parser.parseUnsignedNumber(3);
×
29
    this.user          = parser.parseNullTerminatedString();
×
30
    this.scrambleBuff  = parser.parseBuffer(8);
×
31
    this.database      = parser.parseLengthCodedBuffer();
×
32
  }
33
};
34

35
ClientAuthenticationPacket.prototype.write = function(writer) {
396✔
36
  if (this.protocol41) {
366!
37
    writer.writeUnsignedNumber(4, this.clientFlags);
366✔
38
    writer.writeUnsignedNumber(4, this.maxPacketSize);
366✔
39
    writer.writeUnsignedNumber(1, this.charsetNumber);
366✔
40
    writer.writeFiller(23);
366✔
41
    writer.writeNullTerminatedString(this.user);
366✔
42
    writer.writeLengthCodedBuffer(this.scrambleBuff);
366✔
43
    writer.writeNullTerminatedString(this.database);
366✔
44
  } else {
45
    writer.writeUnsignedNumber(2, this.clientFlags);
×
46
    writer.writeUnsignedNumber(3, this.maxPacketSize);
×
47
    writer.writeNullTerminatedString(this.user);
×
48
    writer.writeBuffer(this.scrambleBuff);
×
49
    if (this.database && this.database.length) {
×
50
      writer.writeFiller(1);
×
51
      writer.writeBuffer(Buffer.from(this.database));
×
52
    }
53
  }
54
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc