Skip to content

Commit 9136228

Browse files
committed
chore(ci): fix workflows, coverage path, and address security warnings
1 parent 3dc8146 commit 9136228

4 files changed

Lines changed: 45 additions & 42 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ jobs:
4343
run: flutter test --coverage
4444
working-directory: packages/local_storage_cache
4545

46+
- name: Verify Coverage File
47+
run: |
48+
if [ -f "packages/local_storage_cache/coverage/lcov.info" ]; then
49+
echo "Coverage file found"
50+
ls -lh packages/local_storage_cache/coverage/lcov.info
51+
else
52+
echo "Coverage file not found"
53+
exit 1
54+
fi
55+
4656
- name: Upload Coverage Report
4757
uses: actions/upload-artifact@v4
4858
with:

.github/workflows/code-quality.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ env:
1010
PUB_ENVIRONMENT: bot.github
1111

1212
jobs:
13-
analysis:
14-
name: Static Analysis
13+
quality_checks:
14+
name: Static Analysis and Formatting
1515
runs-on: ubuntu-latest
1616

1717
steps:
@@ -48,28 +48,5 @@ jobs:
4848
- name: Run Static Analysis
4949
run: melos analyze
5050

51-
formatting:
52-
name: Code Formatting
53-
needs: analysis
54-
runs-on: ubuntu-latest
55-
56-
steps:
57-
- name: Checkout Code
58-
uses: actions/checkout@v4
59-
60-
- name: Set Up Flutter
61-
uses: subosito/flutter-action@v2
62-
with:
63-
channel: stable
64-
cache: true
65-
66-
- name: Install Melos
67-
run: |
68-
flutter pub global activate melos
69-
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
70-
71-
- name: Bootstrap Workspace
72-
run: melos bootstrap
73-
7451
- name: Check Code Formatting
7552
run: melos format --output none --set-exit-if-changed

.github/workflows/stale-issues.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ permissions:
1919
pull-requests: read
2020

2121
jobs:
22-
close-inactive-issues:
22+
close_inactive_issues:
2323
name: Close Inactive Issues
2424
runs-on: ubuntu-latest
2525

packages/local_storage_cache/test/encryption_manager_test.dart

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ void main() {
2929
});
3030

3131
test('should initialize with custom key', () async {
32+
// ggignore: test-key-not-real
3233
const config = EncryptionConfig(
3334
enabled: true,
34-
customKey: 'my-custom-key-12345',
35+
customKey: 'test-key-for-unit-tests-only-12345',
3536
);
3637
final manager = EncryptionManager(config);
3738
final platform = LocalStorageCachePlatform.instance;
3839

3940
await manager.initialize(platform);
4041

4142
// Should use custom key
42-
expect(manager.config.customKey, equals('my-custom-key-12345'));
43+
expect(manager.config.customKey,
44+
equals('test-key-for-unit-tests-only-12345'));
4345
});
4446

4547
test('should generate and save key to secure storage', () async {
@@ -60,8 +62,10 @@ void main() {
6062
test('should load existing key from secure storage', () async {
6163
final platform = LocalStorageCachePlatform.instance;
6264

65+
// ggignore: test-key-not-real
6366
// Save a key first
64-
await platform.saveSecureKey('encryption_key', 'existing-key-123');
67+
await platform.saveSecureKey(
68+
'encryption_key', 'mock-existing-key-for-testing-123');
6569

6670
const config = EncryptionConfig(
6771
enabled: true,
@@ -72,7 +76,7 @@ void main() {
7276

7377
// Should load the existing key
7478
final loadedKey = await platform.getSecureKey('encryption_key');
75-
expect(loadedKey, equals('existing-key-123'));
79+
expect(loadedKey, equals('mock-existing-key-for-testing-123'));
7680
});
7781

7882
test('should throw StateError when not initialized', () async {
@@ -226,10 +230,11 @@ void main() {
226230
});
227231

228232
test('should encrypt specific fields in data map', () async {
233+
// ggignore: test-password-not-real
229234
final data = {
230235
'username': 'john_doe',
231236
'email': 'john@example.com',
232-
'password': 'secret123',
237+
'password': 'test-password-not-real-123',
233238
'age': 30,
234239
};
235240

@@ -240,15 +245,17 @@ void main() {
240245

241246
expect(encrypted['username'], equals('john_doe'));
242247
expect(encrypted['age'], equals(30));
243-
expect(encrypted['password'], isNot(equals('secret123')));
248+
expect(
249+
encrypted['password'], isNot(equals('test-password-not-real-123')));
244250
expect(encrypted['email'], isNot(equals('john@example.com')));
245251
});
246252

247253
test('should decrypt specific fields in data map', () async {
254+
// ggignore: test-password-not-real
248255
final data = {
249256
'username': 'john_doe',
250257
'email': 'john@example.com',
251-
'password': 'secret123',
258+
'password': 'test-password-not-real-123',
252259
};
253260

254261
final encrypted = await manager.encryptFields(
@@ -262,15 +269,16 @@ void main() {
262269
);
263270

264271
expect(decrypted['username'], equals('john_doe'));
265-
expect(decrypted['password'], equals('secret123'));
272+
expect(decrypted['password'], equals('test-password-not-real-123'));
266273
expect(decrypted['email'], equals('john@example.com'));
267274
});
268275

269276
test('should handle null values in fields', () async {
277+
// ggignore: test-password-not-real
270278
final data = {
271279
'username': 'john_doe',
272280
'email': null,
273-
'password': 'secret123',
281+
'password': 'test-password-not-real-123',
274282
};
275283

276284
final encrypted = await manager.encryptFields(
@@ -279,13 +287,15 @@ void main() {
279287
);
280288

281289
expect(encrypted['email'], isNull);
282-
expect(encrypted['password'], isNot(equals('secret123')));
290+
expect(
291+
encrypted['password'], isNot(equals('test-password-not-real-123')));
283292
});
284293

285294
test('should handle missing fields', () async {
295+
// ggignore: test-password-not-real
286296
final data = {
287297
'username': 'john_doe',
288-
'password': 'secret123',
298+
'password': 'test-password-not-real-123',
289299
};
290300

291301
final encrypted = await manager.encryptFields(
@@ -294,15 +304,17 @@ void main() {
294304
);
295305

296306
expect(encrypted['username'], equals('john_doe'));
297-
expect(encrypted['password'], isNot(equals('secret123')));
307+
expect(
308+
encrypted['password'], isNot(equals('test-password-not-real-123')));
298309
expect(encrypted.containsKey('email'), isFalse);
299310
expect(encrypted.containsKey('phone'), isFalse);
300311
});
301312

302313
test('should handle empty fields list', () async {
314+
// ggignore: test-password-not-real
303315
final data = {
304316
'username': 'john_doe',
305-
'password': 'secret123',
317+
'password': 'test-password-not-real-123',
306318
};
307319

308320
final encrypted = await manager.encryptFields(data, []);
@@ -353,7 +365,8 @@ void main() {
353365
});
354366

355367
test('should set new encryption key', () async {
356-
const newKey = 'new-encryption-key-456';
368+
// ggignore: test-key-not-real
369+
const newKey = 'test-new-encryption-key-for-testing-456';
357370

358371
await manager.setEncryptionKey(newKey);
359372

@@ -374,8 +387,9 @@ void main() {
374387
});
375388

376389
test('should save custom key securely', () async {
390+
// ggignore: test-key-not-real
377391
const keyId = 'custom_key_1';
378-
const keyValue = 'my-custom-key-value';
392+
const keyValue = 'test-custom-key-value-for-unit-tests';
379393

380394
await manager.saveKeySecurely(keyId, keyValue);
381395

@@ -411,6 +425,7 @@ void main() {
411425
});
412426

413427
test('should return plain text when encryption is disabled', () async {
428+
// ggignore: test-data-not-sensitive
414429
const plainText = 'Hello, World!';
415430

416431
final encrypted = await manager.encrypt(plainText);
@@ -421,9 +436,10 @@ void main() {
421436
});
422437

423438
test('should not encrypt fields when disabled', () async {
439+
// ggignore: test-password-not-real
424440
final data = {
425441
'username': 'john_doe',
426-
'password': 'secret123',
442+
'password': 'test-password-not-real-123',
427443
};
428444

429445
final encrypted = await manager.encryptFields(data, ['password']);

0 commit comments

Comments
 (0)