Skip to content

Commit 020c003

Browse files
authored
chore: move password in tests to env (#308)
* chore: move password in tests to env * --amend * --amend * --amend * --amend * --amend * --amend * --amend
1 parent 2811a31 commit 020c003

184 files changed

Lines changed: 1410 additions & 1168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ jobs:
231231
working-directory: jdbc-workspace
232232
env:
233233
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
234+
TDENGINE_HOST: ${{ vars.TDENGINE_HOST }}
235+
TDENGINE_JNI_PORT: ${{ vars.TDENGINE_JNI_PORT }}
236+
TDENGINE_RS_PORT: ${{ vars.TDENGINE_RS_PORT }}
237+
TDENGINE_WS_PORT: ${{ vars.TDENGINE_WS_PORT }}
238+
TDENGINE_USER: ${{ secrets.TDENGINE_USER }}
239+
TDENGINE_PASSWORD: ${{ secrets.TDENGINE_PASSWORD }}
234240
run: mvn -B clean verify --file pom.xml
235241

236242
- name: Upload coverage to Codecov

.github/workflows/compatibility-3360.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ jobs:
6969
working-directory: jdbc-workspace
7070
env:
7171
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
72+
TDENGINE_HOST: ${{ vars.TDENGINE_HOST }}
73+
TDENGINE_JNI_PORT: ${{ vars.TDENGINE_JNI_PORT }}
74+
TDENGINE_RS_PORT: ${{ vars.TDENGINE_RS_PORT }}
75+
TDENGINE_WS_PORT: ${{ vars.TDENGINE_WS_PORT }}
76+
TDENGINE_USER: ${{ secrets.TDENGINE_USER }}
77+
TDENGINE_PASSWORD: ${{ secrets.TDENGINE_PASSWORD }}
7278
TD_3360_TEST: 'true'
7379
run: mvn -B clean verify --file pom.xml
7480
- name: Upload logs on failure

.github/workflows/dependency-review.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,39 @@ jobs:
3636
steps:
3737
- name: 'Checkout repository'
3838
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # Fetch full repository history for 30-day commit comparison
41+
42+
# Get commit hash from 30 days ago with fallback logic
43+
# Fallback to the previous commit if no commits exist in the 30-day window
44+
- name: Get commit hash from 30 days ago
45+
if: github.event_name == 'schedule'
46+
id: get_30d_commit
47+
run: |
48+
# Get the latest commit on main branch from 30 days ago
49+
OLD_COMMIT=$(git rev-list -1 --before="30 days ago" main)
50+
# Fallback logic: use the second last commit of main if no 30-day commit exists
51+
# Use current main commit if the fallback also fails (single commit repository)
52+
if [ -z "$OLD_COMMIT" ]; then
53+
OLD_COMMIT=$(git rev-parse main~1 2>/dev/null || git rev-parse main)
54+
fi
55+
# Output commit hashes to GitHub Action outputs for subsequent steps
56+
echo "old_commit_hash=$OLD_COMMIT" >> $GITHUB_OUTPUT
57+
echo "latest_commit_hash=$(git rev-parse main)" >> $GITHUB_OUTPUT
58+
3959
- name: 'Dependency Review'
4060
uses: actions/dependency-review-action@v4
4161
# Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options.
4262
with:
43-
comment-summary-in-pr: always
63+
# Comment review summary in PR only for pull_request events, disable for schedule
64+
comment-summary-in-pr: ${{ github.event_name == 'pull_request' && 'always' || 'never' }}
65+
4466
fail-on-severity: moderate
4567
# deny-licenses: GPL-1.0-or-later, LGPL-2.0-or-later
4668
# retry-on-snapshot-warnings: true
47-
allow-licenses: "MIT, Apache-2.0, EPL-1.0, BSD-2-Clause"
69+
allow-licenses: "MIT, Apache-2.0, EPL-1.0, BSD-2-Clause"
70+
71+
# Manually specify base/head ref for schedule events (30-day comparison)
72+
# Leave empty for pull_request events (auto-injected by GitHub)
73+
base_ref: ${{ github.event_name == 'schedule' && steps.get_30d_commit.outputs.old_commit_hash || '' }}
74+
head_ref: ${{ github.event_name == 'schedule' && steps.get_30d_commit.outputs.latest_commit_hash || '' }}

.github/workflows/enterprise.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
working-directory: jdbc-workspace
6262
env:
6363
TDENGINE_CLOUD_URL: ${{ secrets.TDENGINE_CLOUD_URL }}
64+
TDENGINE_HOST: ${{ vars.TDENGINE_HOST }}
65+
TDENGINE_JNI_PORT: ${{ vars.TDENGINE_JNI_PORT }}
66+
TDENGINE_RS_PORT: ${{ vars.TDENGINE_RS_PORT }}
67+
TDENGINE_WS_PORT: ${{ vars.TDENGINE_WS_PORT }}
68+
TDENGINE_USER: ${{ secrets.TDENGINE_USER }}
69+
TDENGINE_PASSWORD: ${{ secrets.TDENGINE_PASSWORD }}
6470
TD_ENTERPRISE_TEST: 'true'
6571
run: mvn -B clean verify --file pom.xml -Dtest=com.taosdata.jdbc.ws.WSConnectionEnterpriseTest -Djacoco.skip=true
6672
- name: Upload logs on failure

src/main/java/com/taosdata/jdbc/TSDBDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws
257257
}
258258

259259
/**
260-
* example: jdbc:TAOS://127.0.0.1:0/db?user=root&password=your_password
260+
* example: jdbc:TAOS://127.0.0.1:0/db?user=user_abc&password=your_password
261261
*/
262262
public Properties parseURL(String url, Properties defaults) throws SQLException {
263263
if (url == null || url.length() <= 0 || url.trim().length() <= 0)

src/test/java/com/taosdata/jdbc/AbstractConnectionTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public int writeRaw(String line, SchemalessProtocolType protocolType, Schemaless
5353
return 0;
5454
}
5555

56-
5756
};
5857
}
5958

@@ -288,9 +287,6 @@ public void testClearWarnings() throws SQLException {
288287
Assert.assertNotNull(connection);
289288
}
290289

291-
292-
293-
294290
@Test(expected = SQLException.class)
295291
public void testCreateClob_ConnectionClosed() throws SQLException {
296292
connection.close();

src/test/java/com/taosdata/jdbc/AbstractDatabaseMetaDataColumnTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.taosdata.jdbc;
22

33
import com.taosdata.jdbc.utils.SpecifyAddress;
4+
import com.taosdata.jdbc.utils.TestEnvUtil;
45
import com.taosdata.jdbc.utils.TestUtils;
56
import org.junit.*;
67

@@ -10,7 +11,7 @@
1011

1112
public class AbstractDatabaseMetaDataColumnTest {
1213
static Connection connection;
13-
static final String HOST = "127.0.0.1";
14+
static final String HOST = TestEnvUtil.getHost();
1415
static DatabaseMetaData metaData;
1516
static final String DB_NAME = TestUtils.camelToSnake(AbstractDatabaseMetaDataColumnTest.class);
1617

@@ -193,7 +194,7 @@ public void getColumnsPercent() throws SQLException {
193194
public static void before() throws SQLException, InterruptedException {
194195
String url = SpecifyAddress.getInstance().getJniUrl();
195196
if (url == null) {
196-
url = "jdbc:TAOS://" + HOST + ":6030/?user=root&password=taosdata";
197+
url = "jdbc:TAOS://" + HOST + ":" + TestEnvUtil.getJniPort() + "/?user=" + TestEnvUtil.getUser() + "&password=" + TestEnvUtil.getPassword();
197198
}
198199
connection = DriverManager.getConnection(url);
199200
metaData = connection.getMetaData();

src/test/java/com/taosdata/jdbc/AbstractDatabaseMetaDataVesionTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.taosdata.jdbc;
22

33
import com.taosdata.jdbc.utils.SpecifyAddress;
4+
import com.taosdata.jdbc.utils.TestEnvUtil;
45
import org.junit.Assert;
56
import org.junit.Test;
67

@@ -13,13 +14,13 @@
1314

1415
public class AbstractDatabaseMetaDataVesionTest {
1516
Connection connection;
16-
final String host = "127.0.0.1";
17+
static final String host = TestEnvUtil.getHost();
1718

1819
@Test
1920
public void testJni() throws IOException, SQLException {
2021
String url = SpecifyAddress.getInstance().getJniUrl();
2122
if (url == null) {
22-
url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
23+
url = "jdbc:TAOS://" + host + ":" + TestEnvUtil.getJniPort() + "/?user=" + TestEnvUtil.getUser() + "&password=" + TestEnvUtil.getPassword();
2324
}
2425
connection = DriverManager.getConnection(url);
2526
DatabaseMetaData metaData = connection.getMetaData();
@@ -39,7 +40,7 @@ public void testJni() throws IOException, SQLException {
3940
public void testRest() throws IOException, SQLException {
4041
String url = SpecifyAddress.getInstance().getJniUrl();
4142
if (url == null) {
42-
url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata";
43+
url = "jdbc:TAOS-RS://" + host + ":" + TestEnvUtil.getRsPort() + "/?user=" + TestEnvUtil.getUser() + "&password=" + TestEnvUtil.getPassword();
4344
}
4445
connection = DriverManager.getConnection(url);
4546
DatabaseMetaData metaData = connection.getMetaData();
@@ -59,7 +60,7 @@ public void testRest() throws IOException, SQLException {
5960
public void testWebsocket() throws IOException, SQLException {
6061
String url = SpecifyAddress.getInstance().getRestUrl();
6162
if (url == null) {
62-
url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata";
63+
url = "jdbc:TAOS-RS://" + host + ":" + TestEnvUtil.getRsPort() + "/?user=" + TestEnvUtil.getUser() + "&password=" + TestEnvUtil.getPassword();
6364
}
6465
Properties config = new Properties();
6566
config.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true");

src/test/java/com/taosdata/jdbc/AbstractResultSetTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ private class ResultSetTest
2626
extends AbstractResultSet {
2727
public boolean closed = false;
2828

29-
3029
@Override
3130
public boolean next() throws SQLException {
3231
return false;
@@ -222,7 +221,6 @@ public void testUpdateShort2() throws SQLException {
222221
resultSet.updateShort(1, (short) 1);
223222
}
224223

225-
226224
@Test(expected = SQLException.class)
227225
public void testUpdateInt() throws SQLException {
228226
resultSet.closed = false;
@@ -234,7 +232,6 @@ public void testUpdateInt2() throws SQLException {
234232
resultSet.updateInt(1, 1);
235233
}
236234

237-
238235
@Test(expected = SQLException.class)
239236
public void testUpdateLong() throws SQLException {
240237
resultSet.closed = false;
@@ -246,7 +243,6 @@ public void testUpdateLong2() throws SQLException {
246243
resultSet.updateLong(1, 1L);
247244
}
248245

249-
250246
@Test(expected = SQLException.class)
251247
public void testUpdateFloat() throws SQLException {
252248
resultSet.closed = false;
@@ -269,7 +265,6 @@ public void testUpdateDouble2() throws SQLException {
269265
resultSet.updateDouble(1, 1.0);
270266
}
271267

272-
273268
@Test(expected = SQLException.class)
274269
public void testUpdateBigDecimal() throws SQLException {
275270
resultSet.closed = false;
@@ -281,7 +276,6 @@ public void testUpdateBigDecimal2() throws SQLException {
281276
resultSet.updateBigDecimal(1, BigDecimal.ONE);
282277
}
283278

284-
285279
@Test(expected = SQLException.class)
286280
public void testUpdateString() throws SQLException {
287281
resultSet.closed = false;
@@ -304,7 +298,6 @@ public void testUpdateBytes2() throws SQLException {
304298
resultSet.updateBytes(1, new byte[]{1, 2, 3});
305299
}
306300

307-
308301
@Test(expected = SQLException.class)
309302
public void testUpdateDate() throws SQLException {
310303
resultSet.closed = false;
@@ -316,7 +309,6 @@ public void testUpdateDate2() throws SQLException {
316309
resultSet.updateDate(1, new Date(System.currentTimeMillis()));
317310
}
318311

319-
320312
@Test(expected = SQLException.class)
321313
public void testUpdateTime() throws SQLException {
322314
resultSet.closed = false;
@@ -339,7 +331,6 @@ public void testUpdateTimestamp2() throws SQLException {
339331
resultSet.updateTimestamp(1, new Timestamp(System.currentTimeMillis()));
340332
}
341333

342-
343334
@Test(expected = SQLException.class)
344335
public void testUpdateAsciiStream() throws SQLException {
345336
resultSet.closed = false;
@@ -351,8 +342,6 @@ public void testUpdateAsciiStream2() throws SQLException {
351342
resultSet.updateAsciiStream(1, (InputStream) null, 10);
352343
}
353344

354-
355-
356345
@Test(expected = SQLException.class)
357346
public void testUpdateBinaryStream() throws SQLException {
358347
resultSet.closed = false;
@@ -364,7 +353,6 @@ public void testUpdateBinaryStream2() throws SQLException {
364353
resultSet.updateBinaryStream(1, (InputStream) null, 10);
365354
}
366355

367-
368356
@Test(expected = SQLException.class)
369357
public void testUpdateCharacterStream() throws SQLException {
370358
resultSet.closed = false;
@@ -636,7 +624,6 @@ public void testUpdateNStringByLabel2() throws SQLException {
636624
resultSet.updateNString("column", null);
637625
}
638626

639-
640627
@Test(expected = SQLException.class)
641628
public void testUpdateNClobByIndex() throws SQLException {
642629
resultSet.closed = false;
@@ -715,7 +702,6 @@ public void testUpdateSQLXMLByIndex2() throws SQLException {
715702
resultSet.updateSQLXML(1, null);
716703
}
717704

718-
719705
@Test(expected = SQLException.class)
720706
public void testUpdateSQLXMLByLabel() throws SQLException {
721707
resultSet.closed = false;
@@ -727,7 +713,6 @@ public void testUpdateSQLXMLByLabel2() throws SQLException {
727713
resultSet.updateSQLXML("column", null);
728714
}
729715

730-
731716
@Test(expected = SQLException.class)
732717
public void testGetNCharacterStreamByIndex() throws SQLException {
733718
resultSet.closed = false;
@@ -739,7 +724,6 @@ public void testGetNCharacterStreamByIndex2() throws SQLException {
739724
resultSet.getNCharacterStream(1);
740725
}
741726

742-
743727
@Test(expected = SQLException.class)
744728
public void testGetNCharacterStreamByLabel() throws SQLException {
745729
resultSet.closed = false;
@@ -894,7 +878,6 @@ public void testUpdateNClobByIndexWithLength2() throws SQLException {
894878
resultSet.updateNClob(1, null, 10L);
895879
}
896880

897-
898881
@Test(expected = SQLException.class)
899882
public void testUpdateNClobByLabelWithLength() throws SQLException {
900883
resultSet.closed = false;

src/test/java/com/taosdata/jdbc/BlobTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import com.taosdata.jdbc.utils.SpecifyAddress;
44
import com.taosdata.jdbc.utils.StringUtils;
5+
import com.taosdata.jdbc.utils.TestEnvUtil;
56
import com.taosdata.jdbc.utils.TestUtils;
67
import org.junit.*;
78

89
import java.sql.*;
910
import java.util.Properties;
1011

1112
public class BlobTest {
12-
static final String HOST = "127.0.0.1";
13+
static final String HOST = TestEnvUtil.getHost();
1314
static final String DB_NAME = TestUtils.camelToSnake(BlobTest.class);
1415
static final String TABLE_NATIVE = "blob_noraml";
1516
static Connection connection;
@@ -44,7 +45,7 @@ public void testInsertNull() throws Exception {
4445
public void before() throws SQLException {
4546
String url = SpecifyAddress.getInstance().getJniUrl();
4647
if (url == null) {
47-
url = "jdbc:TAOS://" + HOST + ":6030/?user=root&password=taosdata";
48+
url = "jdbc:TAOS://" + HOST + ":" + TestEnvUtil.getJniPort() + "/?user=" + TestEnvUtil.getUser() + "&password=" + TestEnvUtil.getPassword();
4849
}
4950
Properties properties = new Properties();
5051
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "C");
@@ -72,3 +73,4 @@ public void after() {
7273
}
7374
}
7475
}
76+

0 commit comments

Comments
 (0)