Skip to content
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

chore: adding salesforce oauth sandbox support for closed testing #1732

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

shrouti1507
Copy link
Contributor

@shrouti1507 shrouti1507 commented Oct 3, 2024

What are the changes introduced in this PR?

Write a brief explainer on your code changes.

What is the related Linear task?

Resolves INT-2736

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new checks got introduced or modified in test suites. Please explain the changes.

N/A


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • I have executed schemaGenerator tests and updated schema if needed

  • Are sensitive fields marked as secret in definition config?

  • My test cases and placeholders use only masked/sample values for sensitive fields

  • Is the PR limited to 10 file changes & one task?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration for the Salesforce OAuth Sandbox, enabling audience targeting and visual mapping.
    • Added a comprehensive JSON schema for managing consent and cookie categories across multiple platforms.
    • Launched a user interface configuration structure for managing settings related to consent and mapping properties.
  • Bug Fixes

    • Resolved issues related to connection modes for various platforms.
  • Tests

    • Added a suite of test cases to validate configurations related to consent management and cookie categories.

Copy link

coderabbitai bot commented Oct 8, 2024

Walkthrough

A new configuration for the Salesforce OAuth Sandbox has been introduced, comprising two new files: db-config.json and schema.json. These files define the destination's properties and schema for validation, respectively. The changes establish a structured approach for managing the Salesforce OAuth Sandbox destination, including audience support, consent management, and connection modes.

Changes

File Path Change Summary
src/configurations/destinations/salesforce_oauth_sandbox/db-config.json New configuration file defining properties for the Salesforce OAuth Sandbox destination.
src/configurations/destinations/salesforce_oauth_sandbox/schema.json New JSON schema for validating configurations related to consent management and cookie categories.

Poem

In the sandbox where dreams take flight,
Salesforce dances, oh what a sight!
With settings and schemas, all in a row,
Consent and cookies, watch them glow!
A rabbit's delight, hopping with glee,
For changes so bright, come celebrate with me! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0dee98a and d6dec93.

📒 Files selected for processing (1)
  • src/configurations/destinations/salesforce_oauth_sandbox/db-config.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/configurations/destinations/salesforce_oauth_sandbox/db-config.json

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

utsabc
utsabc previously approved these changes Oct 8, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (7)
src/configurations/destinations/salesforce_oauth_sandbox/db-config.json (2)

1-6: Remove trailing space in display name

The displayName value has a trailing space, which might be unintentional. Consider removing it for consistency.

-  "displayName": "Salesforce Sandbox V2 ",
+  "displayName": "Salesforce Sandbox V2",

105-113: Options configuration looks good, consider documenting AMP feature flag

The options configuration, including the beta status and hidden feature flag for AMP integration, is appropriate. However, consider adding a comment or documentation about the purpose and usage of the AMP_salesforce_sandbox_acorns feature flag to improve maintainability.

Consider adding a comment explaining the AMP feature flag:

  "options": {
    "hidden": {
      "featureFlagName": "AMP_salesforce_sandbox_acorns",
-      "featureFlagValue": false
+      "featureFlagValue": false,
+      "_comment": "This feature flag controls the availability of AMP integration for Salesforce Sandbox"
    },
    "beta": true
  }
test/data/validation/destinations/salesforce_oauth_sandbox.json (4)

56-109: LGTM: Comprehensive test cases for invalid consent management configurations.

These test cases effectively cover important edge cases for consent management configuration:

  1. Invalid resolutionStrategy value (lines 56-75)
  2. Missing resolutionStrategy value (lines 76-94)
  3. OneTrust provider without resolutionStrategy (lines 95-109)

The expected results and error messages are appropriate for each case.

Suggestion for improvement: Consider adding a test case for a valid custom provider configuration with a correct resolutionStrategy value to ensure the validation logic works correctly for both valid and invalid cases.


126-244: LGTM: Comprehensive test for oneTrustCookieCategories and ketchConsentPurposes.

This test case effectively covers a wide range of valid configurations for both oneTrustCookieCategories and ketchConsentPurposes across multiple platforms. It includes various scenarios such as empty arrays, environment variables, and template expressions.

Suggestion for improvement: Consider breaking this large test case into smaller, more focused test cases for each platform or specific scenario. This would improve maintainability and make it easier to identify issues if they arise in the future.

For example:

{
  "testTitle": "Valid oneTrustCookieCategories for Android",
  "config": {
    "mapProperties": true,
    "useContactId": true,
    "oneTrustCookieCategories": {
      "android": [
        { "oneTrustCookieCategory": "C0001" },
        { "oneTrustCookieCategory": "C0002" }
      ]
    }
  },
  "result": true
},
{
  "testTitle": "Valid ketchConsentPurposes with environment variable",
  "config": {
    "mapProperties": true,
    "useContactId": true,
    "ketchConsentPurposes": {
      "amp": [
        { "purpose": "env.ENVIRONMENT_VARIABLE" }
      ]
    }
  },
  "result": true
}

This approach would make the test suite more modular and easier to maintain.


269-344: LGTM: Comprehensive test for invalid configurations in consent-related properties.

This test case effectively covers a wide range of invalid configurations for both oneTrustCookieCategories and ketchConsentPurposes. It includes scenarios such as overly long strings, non-string values, and incorrect array structures. The expected false result and the specific error messages are appropriate and helpful for identifying the exact issues in each part of the configuration.

Suggestion for improvement: Consider breaking this large test case into smaller, more focused test cases for each type of invalid configuration. This would improve maintainability and make it easier to identify and debug specific issues in the future.

For example:

{
  "testTitle": "Invalid oneTrustCookieCategory - String too long",
  "config": {
    "mapProperties": true,
    "useContactId": true,
    "oneTrustCookieCategories": {
      "android": [
        {
          "oneTrustCookieCategory": "more than 100 characters string - AAAA..."
        }
      ]
    }
  },
  "result": false,
  "err": [
    "oneTrustCookieCategories.android.0.oneTrustCookieCategory must match pattern \"(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$\""
  ]
},
{
  "testTitle": "Invalid ketchConsentPurposes - Non-string value",
  "config": {
    "mapProperties": true,
    "useContactId": true,
    "ketchConsentPurposes": {
      "ios": [
        {
          "purpose": {
            "not": "a string"
          }
        }
      ]
    }
  },
  "result": false,
  "err": [
    "ketchConsentPurposes.ios.0.purpose must be string"
  ]
}

This approach would make the test suite more modular and easier to maintain, while still covering all the necessary invalid configurations.


1-344: Overall, a comprehensive and well-structured test suite with room for minor improvements.

This test suite for the Salesforce OAuth Sandbox configuration validation is thorough and covers a wide range of scenarios, including both valid and invalid configurations. It effectively tests various aspects such as consent management, OneTrust cookie categories, and Ketch consent purposes across multiple platforms.

Main suggestions for improvement:

  1. Consolidate identical test cases (lines 1-22) into a single test case with a descriptive title.
  2. Break down larger test cases (e.g., lines 126-244 and 269-344) into smaller, more focused tests for better maintainability and easier debugging.
  3. Consider adding a test case for a valid custom provider configuration with a correct resolutionStrategy value (as suggested in the comment for lines 56-109).

These improvements will enhance the overall quality and maintainability of the test suite while maintaining its comprehensive coverage.

src/configurations/destinations/salesforce_oauth_sandbox/schema.json (1)

1-778: Overall assessment: Comprehensive schema with room for improvement.

The schema provides a detailed structure for configuring a Salesforce OAuth sandbox, covering various aspects such as property mapping, contact ID usage, cookie categories, consent management, connection modes, and consent purposes across multiple platforms.

While functional, the schema could benefit from the following improvements:

  1. Refactoring repeated structures (like platform-specific configurations) to reduce duplication.
  2. Simplifying overly complex structures (like connectionMode).
  3. Considering the addition of required properties at the root level.
  4. Evaluating the use of additionalProperties: true at the root level.

Implementing these changes would enhance the schema's maintainability, reduce the potential for errors, and improve its overall robustness.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6339410 and 4c477c7.

📒 Files selected for processing (4)
  • src/configurations/destinations/salesforce_oauth_sandbox/db-config.json (1 hunks)
  • src/configurations/destinations/salesforce_oauth_sandbox/schema.json (1 hunks)
  • src/configurations/destinations/salesforce_oauth_sandbox/ui-config.json (1 hunks)
  • test/data/validation/destinations/salesforce_oauth_sandbox.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (13)
src/configurations/destinations/salesforce_oauth_sandbox/db-config.json (4)

7-15: Authentication and transformation configuration looks good

The authentication setup, transformation configuration, and key management are well-defined and appropriate for a Salesforce OAuth Sandbox integration. The inclusion of consent management and cookie category keys demonstrates attention to privacy considerations.


1-113: Overall, the configuration is well-structured and appropriate

The Salesforce OAuth Sandbox configuration is comprehensive and well-organized. It covers all major platforms, includes necessary consent management features, and is appropriately marked as beta. The suggestions provided in the review are minor and aimed at improving clarity and considering potential enhancements. Please address the comments and verify the points raised to ensure the configuration is robust and future-proof.


29-92: Destination configuration looks good, verify empty secretKeys

The destination configuration is well-structured and consistent across all platforms. The inclusion of consent management and cookie categories is commendable. However, please verify if the empty secretKeys array is intentional or if any secret keys should be added for secure communication with Salesforce.

To verify the secretKeys configuration, run the following script:

#!/bin/bash
# Description: Check secretKeys configuration in other Salesforce integrations

# Test: Search for secretKeys in other Salesforce configurations
rg --type json 'secretKeys' src/configurations/destinations/salesforce*

16-28: 🛠️ Refactor suggestion

Consider supporting additional message types

The configuration currently only supports the "identify" message type. For a more comprehensive Salesforce integration, consider adding support for "track" and "group" message types as well. This would allow for more versatile data syncing capabilities.

-    "supportedMessageTypes": ["identify"],
+    "supportedMessageTypes": ["identify", "track", "group"],

To verify the impact of this change, run the following script:

#!/bin/bash
# Description: Check if other Salesforce configurations support additional message types

# Test: Search for supportedMessageTypes in other Salesforce configurations
rg --type json 'supportedMessageTypes' src/configurations/destinations/salesforce*
src/configurations/destinations/salesforce_oauth_sandbox/ui-config.json (5)

1-20: LGTM: "Other Settings" section is well-structured and clear.

The "Other Settings" section is appropriately configured with two checkbox fields:

  1. "Map Rudder Properties to Salesforce Properties" (default: true)
  2. "Use contactId for converted leads" (default: false)

The labels are clear, and the footer note for the second option provides helpful guidance for users.


21-51: LGTM: OneTrust Consent Category IDs configuration is well-structured.

The configuration for OneTrust Consent Category IDs is clear and includes:

  • Appropriate labeling and placeholder
  • A helpful footer note about using category IDs instead of names
  • A regex pattern for validation
  • Feature flag prerequisites for conditional rendering

52-78: LGTM: Ketch Consent Purpose IDs configuration is consistent with OneTrust.

The Ketch Consent Purpose IDs configuration mirrors the structure of the OneTrust section, maintaining consistency in the UI. It includes:

  • Appropriate labeling and placeholder
  • The same regex pattern for validation
  • Similar feature flag prerequisites for conditional rendering

79-157: LGTM: Consent management settings are comprehensive and well-structured.

The consent management settings section provides a flexible and comprehensive configuration:

  • It allows selection of the consent management provider (Custom, Ketch, OneTrust)
  • Includes a required field for consent logic (AND/OR) when using custom provider
  • Provides a dynamic form for entering consent category IDs
  • Uses appropriate feature flags for conditional rendering

The structure and options provided align well with the PR objective of adding Salesforce OAuth sandbox support for closed testing.


1-161: Overall, the ui-config.json file is well-structured and comprehensive.

The file provides a thorough UI configuration for the Salesforce OAuth Sandbox, covering both general settings and consent management options. Key points:

  1. Consistent use of feature flags for conditional rendering
  2. Clear labeling and helpful footer notes
  3. Comprehensive consent management settings
  4. Appropriate use of dynamic custom forms

The configuration aligns well with the PR objective of adding Salesforce OAuth sandbox support for closed testing. No issues or inconsistencies were found.

test/data/validation/destinations/salesforce_oauth_sandbox.json (3)

23-55: LGTM: Well-structured test case for multiple consent management providers.

This test case effectively covers a scenario with multiple consent management providers, including custom, oneTrust, and ketch. The configuration is comprehensive and the expected result is appropriate.


110-125: LGTM: Effective test for invalid consent management provider.

This test case correctly validates that only allowed provider values are accepted in the consent management configuration. The expected false result and the specific error message are appropriate for this scenario.


245-268: LGTM: Effective test for invalid structure of consent-related properties.

This test case correctly validates that oneTrustCookieCategories and ketchConsentPurposes must be objects, not arrays. The expected false result and the specific error messages are appropriate for this scenario, ensuring proper validation of the structure of these properties.

src/configurations/destinations/salesforce_oauth_sandbox/schema.json (1)

7-14: LGTM: Well-defined boolean properties.

The mapProperties and useContactId boolean properties are clearly defined with appropriate default values.

koladilip
koladilip previously approved these changes Oct 8, 2024
@shrouti1507 shrouti1507 dismissed stale reviews from koladilip and utsabc via 0dee98a October 8, 2024 12:19
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (2)
src/configurations/destinations/salesforce_oauth_sandbox/schema.json (2)

1-14: Consider making essential properties required.

The schema structure looks good, and the use of default values for mapProperties and useContactId is appropriate. However, the empty required array at the schema root level means that no properties are mandatory. Consider if any properties should be required for a valid configuration.


1-777: Overall schema structure is comprehensive but could benefit from refactoring.

The schema for the Salesforce OAuth sandbox configuration is well-structured and covers all necessary aspects, including properties for mapping, contact ID usage, cookie categories, consent management, connection mode, and consent purposes. It provides good flexibility with support for multiple platforms and consent management providers.

The use of string patterns allowing for environment variables and placeholders is a good practice for configuration management. However, the main area for improvement is the repetition of similar structures across different properties (oneTrustCookieCategories, consentManagement, ketchConsentPurposes).

To enhance maintainability and reduce the risk of inconsistencies, consider implementing the refactoring suggestions provided in the previous comments. This would involve creating reusable schema definitions for the repeated structures and referencing them for each platform.

These changes would make the schema more concise, easier to maintain, and less prone to errors when updates are needed across multiple platforms.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4c477c7 and 0dee98a.

📒 Files selected for processing (2)
  • src/configurations/destinations/salesforce_oauth_sandbox/db-config.json (1 hunks)
  • src/configurations/destinations/salesforce_oauth_sandbox/schema.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/configurations/destinations/salesforce_oauth_sandbox/db-config.json
🧰 Additional context used
📓 Learnings (1)
src/configurations/destinations/salesforce_oauth_sandbox/schema.json (1)
Learnt from: shrouti1507
PR: rudderlabs/rudder-integrations-config#1732
File: test/data/validation/destinations/salesforce_oauth_sandbox.json:1-22
Timestamp: 2024-10-08T12:13:04.607Z
Learning: In the `rudder-integrations-config` repository, for closed testing destinations, identical test cases without consolidation are acceptable.

@shrouti1507 shrouti1507 requested a review from utsabc October 8, 2024 12:43
@sanpj2292 sanpj2292 requested a review from koladilip October 8, 2024 13:33
@shrouti1507 shrouti1507 removed the DO NOT MERGE Approved but need to check more label Oct 9, 2024
@shrouti1507 shrouti1507 merged commit 946b54d into develop Oct 9, 2024
11 checks passed
@shrouti1507 shrouti1507 deleted the salesforce-oauth-sandbox branch October 9, 2024 05:15
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (6339410) to head (d6dec93).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop     #1732   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           53        53           
  Branches         7         7           
=========================================
  Hits            53        53           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants