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

Added new connector: Source-Salesforce #1367

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added tests snapshots
Fixed flow.yaml file configs
Luishfs committed Mar 13, 2024
commit 9151d4d26e5cc6685c316c0f89675b4e5c255de7
21 changes: 21 additions & 0 deletions source-salesforce/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
credentials:
auth_type: Client
client_id_sops: ENC[AES256_GCM,data:w+QlOJj6HMkY8LXI+rhkU+WGzrC/pz70nnZMpqrYbLcLBBnd4MAvPOJrY9GCa1CazfzavL6ATXZtMO2et7IT8PH5i4OkhHmXrcRpYvoQFYqVPOsXMw==,iv:lto0AF8YNlhb9FIntaqVRcyxaEZSxhefzCcDx/2yQFw=,tag:BAIe1Yezo1mnaxz/uPfbaQ==,type:str]
client_secret_sops: ENC[AES256_GCM,data:MTa+Cv+YH7v8gy/LTsviFW9oocCDWp86g7aB5OVnO6OJLPChbNAuC7qtAzNKiZu2DVKof9tmrjqQcWxhdVEMJA==,iv:oZg6cFFx9Oq3AZCGsGRtusXEZKyMVMKbG6SCANxjwWg=,tag:iyHdLX2mUFKQfo3oJRCneg==,type:str]
refresh_token_sops: ENC[AES256_GCM,data:ao4MuPvTWERkVyPieScomGZnryhEedaVizY1tOIGIXDewe9DD4dvXbBS3s+uMMG1j8mH2QWM5s7ta3LqChAZ+Tq3+o8KktMZ6D/PR7CjNfumrUrXeVgZ,iv:dHVIGWMkalxkcjCCvzeS/wPsJ5SVgfUNoRIKYoq2eTk=,tag:lWOpuMjSZVHn4nFb/UnpjQ==,type:str]
is_sandbox: false
start_date: "2020-01-01"
sops:
kms: []
gcp_kms:
- resource_id: projects/estuary-theatre/locations/us-central1/keyRings/connector-keyring/cryptoKeys/connector-repository
created_at: "2024-03-08T05:31:16Z"
enc: CiQAdmEdwvWWci8hmYfDEI3t5/hMDMNae/7Pq6THGr3n3y+b8CwSSQCVvC1zN8IPDTYZdbVo11k7xVAeJSNRRAIOPpU+ARe73YpQtoMP92xJs0VasYa6gxjB53wWKIHiGxYJr5rYtJfvE6evYRQFkDY=
azure_kv: []
hc_vault: []
age: []
lastmodified: "2024-03-08T05:31:17Z"
mac: ENC[AES256_GCM,data:f22SroKVPhI6p/24lSCMTSuIjR6orf2jcrGKf1A29MvGpwR9804EaRwnZ6wArq5aqMoeEF4BvZrcbJewqrjNT1qRRPvXb+7e7t/VIPi+8/qH1ID++oLxo/eEvdGMLhtxQSr7x41erqql0izeUyaEU6KgzEo5b0HKM/3FMOQi/z8=,iv:4cjKBY41vOI1ve0ppjbWDp7UWVsnZakEYhDzWTuajLc=,tag:aKpMwjdOnzJ00DNEChRrlw==,type:str]
pgp: []
encrypted_suffix: _sops
version: 3.8.1
1,603 changes: 1,603 additions & 0 deletions source-salesforce/poetry.lock

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions source-salesforce/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tool.poetry]
name = "source-salesforce"
version = "0.1.0"
description = ""
authors = ["Luishfs <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.11,<3.12"
flow-sdk = {path="../python", develop=true}
airbyte-cdk = "0.51.14"
backoff = "^1.11"
pendulum = "^3.0.0"
pandas = "^2.2.1"
vcrpy = "4.1.1"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
pytest-insta = "^0.2.0"
mock = "^5.1.0"
pytest-mock = "^3.12.0"
requests-mock = "^1.11.0"
debugpy = "^1.8.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4,810 changes: 4,810 additions & 0 deletions source-salesforce/test.flow.yaml

Large diffs are not rendered by default.

Empty file.
107,676 changes: 107,676 additions & 0 deletions source-salesforce/tests/snapshots/snapshots__discover__capture.stdout.json
Copy link
Member

Choose a reason for hiding this comment

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

The amount of change in this file is concerning -- it's too large to even review in GitHub. Can you discuss the nature of the changes here? If you re-create this snapshot, after having switched to the estuary-cdk, are there fewer changes (because it was re-orderings introduced by the older flow-sdk that have since reverted to their original snapshot order)?

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions source-salesforce/tests/snapshots/snapshots__spec__capture.stdout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
[
{
"configSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": true,
"properties": {
"credentials": {
"properties": {
"auth_type": {
"const": "Client",
"default": "Client",
"type": "string"
},
"client_id": {
"airbyte_secret": true,
"description": "Enter your Salesforce developer application's Client ID",
"order": 2,
"title": "Client ID",
"type": "string"
},
"client_secret": {
"airbyte_secret": true,
"description": "Enter your Salesforce developer application's Client secret",
"order": 3,
"title": "Client Secret",
"type": "string"
},
"refresh_token": {
"airbyte_secret": true,
"description": "Enter your application's Salesforce Refresh Token used to access your Salesforce account.",
"order": 4,
"title": "Refresh Token",
"type": "string"
}
},
"required": [
"client_id",
"client_secret",
"refresh_token"
],
"type": "object",
"x-oauth2-provider": "salesforce"
},
"is_sandbox": {
"default": false,
"description": "Toggle if you're using a <a href=\"https://help.salesforce.com/s/articleView?id=sf.deploy_sandboxes_parent.htm&type=5\">Salesforce Sandbox</a>",
"order": 1,
"title": "Sandbox",
"type": "boolean"
},
"start_date": {
"description": "Enter the date in the YYYY-MM-DD format. We will replicate the data added on and after this date. If this field is blank, we will replicate all data.",
"examples": [
"2021-07-25T00:00:00Z"
],
"format": "date",
"order": 5,
"pattern": "^([0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?)$",
"title": "Start Date",
"type": "string"
},
"streams_criteria": {
"description": "Filter streams relevant to you",
"items": {
"properties": {
"criteria": {
"default": "contains",
"enum": [
"starts with",
"ends with",
"contains",
"exacts",
"starts not with",
"ends not with",
"not contains",
"not exacts"
],
"order": 1,
"title": "Search criteria",
"type": "string"
},
"value": {
"order": 2,
"title": "Search value",
"type": "string"
}
},
"required": [
"criteria",
"value"
],
"type": "object"
},
"order": 6,
"title": "Filter Salesforce Objects",
"type": "array"
}
},
"required": [
"credentials"
],
"title": "Salesforce Source Spec",
"type": "object"
},
"documentationUrl": "https://go.estuary.dev/AyWXIh",
"oauth2": {
"accessTokenBody": "grant_type=authorization_code&client_id={{#urlencode}}{{{ client_id }}}{{/urlencode}}&client_secret={{#urlencode}}{{{ client_secret }}}{{/urlencode}}&redirect_uri={{#urlencode}}{{{ redirect_uri }}}{{/urlencode}}&code={{#urlencode}}{{{ code }}}{{/urlencode}}",
"accessTokenHeaders": {
"content-type": "application/x-www-form-urlencoded"
},
"accessTokenResponseMap": {
"refresh_token": "/refresh_token"
},
"accessTokenUrlTemplate": "https://{{#config.is_sandbox}}test{{/config.is_sandbox}}{{^config.is_sandbox}}login{{/config.is_sandbox}}.salesforce.com/services/oauth2/token",
"authUrlTemplate": "https://{{#config.is_sandbox}}test{{/config.is_sandbox}}{{^config.is_sandbox}}login{{/config.is_sandbox}}.salesforce.com/services/oauth2/authorize?client_id={{#urlencode}}{{{ client_id }}}{{/urlencode}}&redirect_uri={{#urlencode}}{{{ redirect_uri }}}{{/urlencode}}&response_type=code&state={{#urlencode}}{{{ state }}}{{/urlencode}}",
"provider": "salesforce"
},
"protocol": 3032023,
"resourceConfigSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cursorField": {
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
},
"namespace": {
"type": [
"string",
"null"
]
},
"stream": {
"type": "string"
},
"syncMode": {
"enum": [
"incremental",
"full_refresh"
],
"type": "string"
}
},
"required": [
"stream",
"syncMode"
],
"title": "ResourceSpec",
"type": "object"
},
"resourcePathPointers": [
"/namespace",
"/stream"
]
}
]
58 changes: 58 additions & 0 deletions source-salesforce/tests/test_snapshots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import json
import subprocess

import pytest_insta.format as insta_format
insta_format.FmtJson.dump = lambda _self, path, value: path.write_text(json.dumps(value, sort_keys=True, indent=2) + "\n", "utf-8")

# def test_capture(request, snapshot):
# result = subprocess.run(
# [
# "flowctl",
# "preview",
# "--source",
# request.config.rootdir + "/source-hubspot/test.flow.yaml",
# ],
# stdout=subprocess.PIPE,
# text=True,
# )
# assert result.returncode == 0
# lines = [json.loads(l) for l in result.stdout.splitlines()]

# assert snapshot("capture.stdout.json") == lines

def test_discover(request, snapshot):
result = subprocess.run(
[
"flowctl",
"raw",
"discover",
"--source",
request.config.rootdir + "/source-salesforce/test.flow.yaml",
"-o",
"json",
"--emit-raw"
],
stdout=subprocess.PIPE,
text=True,
)
assert result.returncode == 0
lines = [json.loads(l) for l in result.stdout.splitlines()]

assert snapshot("capture.stdout.json") == lines

def test_spec(request, snapshot):
result = subprocess.run(
[
"flowctl",
"raw",
"spec",
"--source",
request.config.rootdir + "/source-salesforce/test.flow.yaml"
],
stdout=subprocess.PIPE,
text=True,
)
assert result.returncode == 0
lines = [json.loads(l) for l in result.stdout.splitlines()]

assert snapshot("capture.stdout.json") == lines