Skip to content

Commit df696b1

Browse files
committed
refactor: Rename postgres-related variable/function names to gaussdb
1 parent b2046ed commit df696b1

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed

packages/gaussdb-protocol/src/inbound-parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ const parseBuffers = async (buffers: Buffer[]): Promise<BackendMessage[]> => {
245245
return msgs
246246
}
247247

248-
describe('PgPacketStream', function () {
248+
describe('GaussDBPacketStream', function () {
249249
testForMessage(authOkBuffer, expectedAuthenticationOkayMessage)
250250
testForMessage(plainPasswordBuffer, expectedPlainPasswordMessage)
251251
testForMessage(md5PasswordBuffer, expectedMD5PasswordMessage)

packages/gaussdb/lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class Client extends EventEmitter {
254254
_handleAuthMD5Password(msg) {
255255
this._checkPgPass(async () => {
256256
try {
257-
const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt)
257+
const hashedPassword = await crypto.gaussdbMd5PasswordHash(this.user, this.password, msg.salt)
258258
this.connection.password(hashedPassword)
259259
} catch (e) {
260260
this.emit('error', e)
@@ -265,7 +265,7 @@ class Client extends EventEmitter {
265265
_handleAuthSHA256Password(msg) {
266266
this._checkPgPass(async () => {
267267
try {
268-
const hashedPassword = await crypto.postgresSha256PasswordHash(this.user, this.password, msg.data)
268+
const hashedPassword = await crypto.gaussdbSha256PasswordHash(this.user, this.password, msg.data)
269269
this.connection.password(hashedPassword)
270270
} catch (e) {
271271
this.emit('error', e)

packages/gaussdb/lib/crypto/utils-legacy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ function md5(string) {
99
}
1010

1111
// See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html
12-
function postgresMd5PasswordHash(user, password, salt) {
12+
function gaussdbMd5PasswordHash(user, password, salt) {
1313
const inner = md5(password + user)
1414
const outer = md5(Buffer.concat([Buffer.from(inner), salt]))
1515
return 'md5' + outer
1616
}
1717

1818
// See AuthenticationSHA256Password (based on similar approach to MD5)
19-
function postgresSha256PasswordHash(user, password, salt) {
19+
function gaussdbSha256PasswordHash(user, password, salt) {
2020
const inner = nodeCrypto
2121
.createHash('sha256')
2222
.update(password + user, 'utf-8')
@@ -46,8 +46,8 @@ async function deriveKey(password, salt, iterations) {
4646
}
4747

4848
module.exports = {
49-
postgresMd5PasswordHash,
50-
postgresSha256PasswordHash,
49+
gaussdbMd5PasswordHash,
50+
gaussdbSha256PasswordHash,
5151
randomBytes: nodeCrypto.randomBytes,
5252
deriveKey,
5353
sha256,

packages/gaussdb/lib/crypto/utils-webcrypto.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const nodeCrypto = require('crypto')
22
const { RFC5802Algorithm } = require('./rfc5802')
33

44
module.exports = {
5-
postgresMd5PasswordHash,
6-
postgresSha256PasswordHash,
5+
gaussdbMd5PasswordHash,
6+
gaussdbSha256PasswordHash,
77
randomBytes,
88
deriveKey,
99
sha256,
@@ -50,13 +50,13 @@ async function md5(string) {
5050
}
5151

5252
// See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html
53-
async function postgresMd5PasswordHash(user, password, salt) {
53+
async function gaussdbMd5PasswordHash(user, password, salt) {
5454
const inner = await md5(password + user)
5555
const outer = await md5(Buffer.concat([Buffer.from(inner), salt]))
5656
return 'md5' + outer
5757
}
5858

59-
async function postgresSha256PasswordHash(user, password, data) {
59+
async function gaussdbSha256PasswordHash(user, password, data) {
6060
// Constants for data structure parsing
6161
const PASSWORD_METHOD_OFFSET = 0
6262
const PASSWORD_METHOD_SIZE = 4

packages/gaussdb/test/integration/client/array-tests.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ pool.connect(
5050
assert(!err)
5151
client.query('CREATE TEMP TABLE why(names text[], numbors integer[])')
5252
client
53-
.query(new gaussdb.Query('INSERT INTO why(names, numbors) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\')'))
53+
.query(
54+
new gaussdb.Query('INSERT INTO why(names, numbors) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\')')
55+
)
5456
.on('error', console.log)
5557
suite.test('numbers', function (done) {
5658
// client.connection.on('message', console.log)

packages/gaussdb/test/integration/client/prepared-statement-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ const suite = new helper.Suite()
128128
const client = helper.client()
129129
client.query('CREATE TEMP TABLE zoom(name varchar(100));')
130130
client.query("INSERT INTO zoom (name) VALUES ('zed')")
131-
client.query("INSERT INTO zoom (name) VALUES ('postgres')")
132-
client.query("INSERT INTO zoom (name) VALUES ('node postgres')")
131+
client.query("INSERT INTO zoom (name) VALUES ('gaussdb')")
132+
client.query("INSERT INTO zoom (name) VALUES ('node gaussdb')")
133133

134134
const checkForResults = function (q) {
135135
assert.emits(q, 'row', function (row) {
136-
assert.equal(row.name, 'node postgres')
136+
assert.equal(row.name, 'gaussdb')
137137

138138
assert.emits(q, 'row', function (row) {
139-
assert.equal(row.name, 'postgres')
139+
assert.equal(row.name, 'node gaussdb')
140140

141141
assert.emits(q, 'row', function (row) {
142142
assert.equal(row.name, 'zed')

packages/gaussdb/test/unit/client/md5-password-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('md5 authentication', async function () {
1616
test('responds', function () {
1717
assert.lengthIs(client.connection.stream.packets, 1)
1818
test('should have correct encrypted data', async function () {
19-
const password = await crypto.postgresMd5PasswordHash(client.user, client.password, salt)
19+
const password = await crypto.gaussdbMd5PasswordHash(client.user, client.password, salt)
2020
// how do we want to test this?
2121
assert.equalBuffers(client.connection.stream.packets[0], new BufferList().addCString(password).join(true, 'p'))
2222
})

packages/gaussdb/test/unit/client/sha256-password-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const test = suite.test.bind(suite)
99
test('sha256 authentication', async function () {
1010
const client = helper.createClient()
1111
client.password = '!'
12-
// Mock SHA256 authentication data following the format expected by postgresSha256PasswordHash, similar to the MD5 test
12+
// Mock SHA256 authentication data following the format expected by gaussdbSha256PasswordHash, similar to the MD5 test
1313
// Structure: [4 bytes method][64 bytes random code][8 bytes token][4 bytes iteration]
1414
const data = Buffer.alloc(80)
1515
data.writeInt32BE(1, 0) // password method. in fact this data is not used in the hashing
@@ -23,7 +23,7 @@ test('sha256 authentication', async function () {
2323
test('responds', function () {
2424
assert.lengthIs(client.connection.stream.packets, 1)
2525
test('should have correct encrypted data', async function () {
26-
const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data)
26+
const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data)
2727
assert.equalBuffers(
2828
client.connection.stream.packets[0],
2929
new BufferList().addCString(hashedPassword).join(true, 'p')
@@ -48,7 +48,7 @@ test('sha256 authentication with empty password', async function () {
4848
test('responds with empty password', function () {
4949
assert.lengthIs(client.connection.stream.packets, 1)
5050
test('should have correct encrypted data for empty password', async function () {
51-
const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data)
51+
const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data)
5252
assert.equalBuffers(
5353
client.connection.stream.packets[0],
5454
new BufferList().addCString(hashedPassword).join(true, 'p')
@@ -73,7 +73,7 @@ test('sha256 authentication with utf-8 password', async function () {
7373
test('responds with utf-8 password', function () {
7474
assert.lengthIs(client.connection.stream.packets, 1)
7575
test('should have correct encrypted data for utf-8 password', async function () {
76-
const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data)
76+
const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data)
7777
assert.equalBuffers(
7878
client.connection.stream.packets[0],
7979
new BufferList().addCString(hashedPassword).join(true, 'p')

0 commit comments

Comments
 (0)