-
Notifications
You must be signed in to change notification settings - Fork 6
New replicator config #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,8 @@ import { | |||||||||||||||||||||
| Collection, | ||||||||||||||||||||||
| MutableDocument, | ||||||||||||||||||||||
| Document, | ||||||||||||||||||||||
| ConcurrencyControl | ||||||||||||||||||||||
| ConcurrencyControl, | ||||||||||||||||||||||
| CollectionConfiguration | ||||||||||||||||||||||
| } from 'cbl-reactnative';import getFileDefaultPath from '@/service/file/getFileDefaultPath'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default function CustomBugFixScreen() { | ||||||||||||||||||||||
|
|
@@ -63,22 +64,28 @@ export default function CustomBugFixScreen() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| const connectToSyncGateway = async () => { | ||||||||||||||||||||||
| setListOfLogs(prev => [...prev, 'Connecting to Sync Gateway']); // ✅ Use prev | ||||||||||||||||||||||
| const defaultCollection = await database?.defaultCollection(); | ||||||||||||||||||||||
| if(database === null || database === undefined) { | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||
| throw Error("Database is undefined") | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| const defaultCollection = await database.defaultCollection(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const syncGatewayUrl = "wss://nasm0fvdr-jnehnb.apps.cloud.couchbase.com:4984/testendpoint" | ||||||||||||||||||||||
| const endpoint = new URLEndpoint(syncGatewayUrl); | ||||||||||||||||||||||
| const username = "jayantdhingra" | ||||||||||||||||||||||
| const password = "f9yu5QT4B5jpZep@" | ||||||||||||||||||||||
|
Comment on lines
74
to
75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded credentials found. Storing secrets like usernames and passwords directly in the source code is a major security risk. These credentials can be easily extracted from the compiled application, even from test files. It's highly recommended to use a secure method for managing secrets, such as environment variables or a secrets management service.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although this is not going into a release branch, I think it would be good to not publish/expose credentials at all on remote. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(endpoint) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const collectionConfig = new CollectionConfiguration(defaultCollection) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const listOfCollectionConfig = [collectionConfig] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint) | ||||||||||||||||||||||
|
Comment on lines
+77
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code formatting in this section has inconsistent indentation and excessive blank lines, which affects readability. It's recommended to remove the extra lines and fix the indentation.
Suggested change
|
||||||||||||||||||||||
| replicatorConfig.setAuthenticator(new BasicAuthenticator(username, password)) | ||||||||||||||||||||||
| // replicatorConfig.setContinuous(true) | ||||||||||||||||||||||
| replicatorConfig.setAcceptOnlySelfSignedCerts(false); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (defaultCollection) { | ||||||||||||||||||||||
| replicatorConfig.addCollection(defaultCollection) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const replicator = await Replicator.create(replicatorConfig) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||||
| import React from 'react'; | ||||||||
| import TestRunnerContainer from '@/components/TestRunnerContainer/TestRunnerContainer'; | ||||||||
|
|
||||||||
| import { ReplicatorNewApiTests } from '../../cblite-js-tests/cblite-tests/e2e/replicator-new-api-test'; | ||||||||
|
|
||||||||
| export default function TestsReplicatorScreen() { | ||||||||
| function reset() {} | ||||||||
|
|
||||||||
| async function update(): Promise<string[]> { | ||||||||
| try { | ||||||||
| return ['']; | ||||||||
| } catch (e) { | ||||||||
| // @ts-ignore | ||||||||
| return [error.message]; | ||||||||
|
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a reference to an undefined variable
Suggested change
|
||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| return ( | ||||||||
| <TestRunnerContainer | ||||||||
| navigationTitle="Replicator Tests" | ||||||||
| subTitle="Run Sync Gate before tests - visit tests README.md" | ||||||||
| testCases={[ReplicatorNewApiTests]} | ||||||||
| /> | ||||||||
| ); | ||||||||
| } | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,8 @@ import { | |||||||||||||||||||||
| ReplicatorConfiguration, | ||||||||||||||||||||||
| URLEndpoint, | ||||||||||||||||||||||
| BasicAuthenticator, | ||||||||||||||||||||||
| MutableDocument | ||||||||||||||||||||||
| MutableDocument, | ||||||||||||||||||||||
| CollectionConfiguration | ||||||||||||||||||||||
| } from 'cbl-reactnative'; | ||||||||||||||||||||||
| import getFileDefaultPath from '@/service/file/getFileDefaultPath'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -61,12 +62,18 @@ export default function ReplicatorListenersScreen() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const endpoint = new URLEndpoint(SYNC_GATEWAY_URL); | ||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(endpoint); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| //Create CollectionConfiguration | ||||||||||||||||||||||
| const collectionConfig = new CollectionConfiguration(defaultCollection); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const listOfCollectionConfig = [collectionConfig] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Pass array of configs and endpoint to constructor | ||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint); | ||||||||||||||||||||||
|
Comment on lines
+66
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comments explaining the API change can be removed as the code is now straightforward. Also, there are extra blank lines and an extra space in the constructor call that can be cleaned up for better readability.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| replicatorConfig.setAuthenticator(new BasicAuthenticator(USERNAME, PASSWORD)); | ||||||||||||||||||||||
| replicatorConfig.setContinuous(true); | ||||||||||||||||||||||
| replicatorConfig.setAcceptOnlySelfSignedCerts(false); | ||||||||||||||||||||||
| replicatorConfig.addCollection(defaultCollection); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const replicator = await Replicator.create(replicatorConfig); | ||||||||||||||||||||||
| setReplicator(replicator); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and to adhere to standard coding practices, each import statement should be on its own line.