diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index c33bb6877b..9df30a8cd1 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -108,3 +108,53 @@ jobs: FILTER: test-select-1|test-select-ssl run: bun run test:bun timeout-minutes: 1 + + tests-linux-deno: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + deno-version: [v1.43.6, canary] + mysql-version: ["mysql:8.0.33"] + use-compression: [0, 1] + use-tls: [0,1] + + name: Deno ${{ matrix.deno-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}} + + steps: + - uses: actions/checkout@v4 + - name: Set up MySQL + run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }} + + - name: Set up Deno ${{ matrix.deno-version }} + uses: denoland/setup-deno@v1 + with: + deno-version: ${{ matrix.deno-version }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: npm-linux-${{ hashFiles('package-lock.json') }} + restore-keys: npm-linux- + + - name: Install npm dependencies + run: npm ci + + - name: Wait mysql server is ready + run: node tools/wait-up.js + + # todo: check what we need to do to run all tests with deno + - name: run tests + env: + MYSQL_USER: ${{ env.MYSQL_USER }} + MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} + MYSQL_PORT: ${{ env.MYSQL_PORT }} + MYSQL_USE_COMPRESSION: ${{ matrix.use-compression }} + MYSQL_USE_TLS: ${{ matrix.use-tls }} + run: deno test --allow-net --allow-env --allow-read test/deno.ts + timeout-minutes: 1 \ No newline at end of file diff --git a/lib/auth_plugins/caching_sha2_password.js b/lib/auth_plugins/caching_sha2_password.js index 4245f934ea..866326363c 100644 --- a/lib/auth_plugins/caching_sha2_password.js +++ b/lib/auth_plugins/caching_sha2_password.js @@ -36,7 +36,10 @@ function encrypt(password, scramble, key) { Buffer.from(`${password}\0`, 'utf8'), scramble ); - return crypto.publicEncrypt(key, stage1); + return crypto.publicEncrypt({ + key, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING + }, stage1); } module.exports = (pluginOptions = {}) => ({ connection }) => { diff --git a/test/deno.ts b/test/deno.ts new file mode 100644 index 0000000000..ae5e6ba987 --- /dev/null +++ b/test/deno.ts @@ -0,0 +1,26 @@ +import { createRequire } from 'node:module'; +const require = createRequire(import.meta.url); +const mysql = require('../index.js'); + +const connection = mysql.createConnection({ + host: Deno.env.get('MYSQL_HOST'), + port: Deno.env.get('MYSQL_PORT'), + user: Deno.env.get('MYSQL_USER'), + password: Deno.env.get('MYSQL_PASSWORD'), + database: Deno.env.get('MYSQL_DATABASE'), +}); + +connection.on('error', (err: Error) => { + console.error(err); + Deno.exit(1); +}); + +connection.on('connect', () => { + connection.query('SELECT 1 + 1 AS solution', (err: Error) => { + if (err) { + console.error(err); + Deno.exit(1); + } + connection.end(); + }); +});