Skip to content

Commit

Permalink
Merge pull request #445 from SFDO-Tooling/feature/profile-id-feature
Browse files Browse the repository at this point in the history
Docs and tests for ProfileID feature
  • Loading branch information
Paul Prescod authored Jul 27, 2021
2 parents 95fb683 + 80d9605 commit 117cfc8
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/salesforce.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,28 @@ To specify a Record Type for a record, just put the Record Type’s API Name in
RecordType: Organization
```

## Profiles

The `Salesforce.ProfileId` function looks up a Profile in
Salesforce by name and substitutes the ID.

```yaml
- plugin: snowfakery.standard_plugins.Salesforce
- object: User
fields:
Alias: Grace
Username:
fake: Username
LastName: Wong
Email: ${{Username}}
TimeZoneSidKey: America/Bogota
LocaleSidKey: en_US
EmailEncodingKey: UTF-8
LanguageLocaleKey: en_US
ProfileId:
Salesforce.ProfileId: Identity User
```

## Creating and Referencing Person Accounts

There are several features planned for the Salesforce Plugin, but
Expand Down
50 changes: 50 additions & 0 deletions examples/salesforce/UsersProfilesPermissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- plugin: snowfakery.standard_plugins.Salesforce
- plugin: snowfakery.standard_plugins.Salesforce.SalesforceQuery

- object: User
fields:
Alias: Grace
Username:
fake: Username
LastName: Wong
Email: ${{Username}}
TimeZoneSidKey: America/Bogota
LocaleSidKey: en_US
EmailEncodingKey: UTF-8
LanguageLocaleKey: en_US
ProfileId:
Salesforce.ProfileId: Identity User

friends:
- object: PermissionSetAssignment
fields:
AssigneeId:
reference: User
PermissionSetId:
SalesforceQuery.find_record:
from: PermissionSet
where: Name='CommerceUser'
- object: PermissionSetAssignment
fields:
AssigneeId:
reference: User
PermissionSetId:
SalesforceQuery.find_record:
from: PermissionSet
where: Name='SalesConsoleUser'
- object: User
nickname: RandomizedUser
fields:
Username:
fake: Username
LastName:
fake: last_name
Email:
fake: email
Alias: Grace
TimeZoneSidKey: America/Bogota
LocaleSidKey: en_US
EmailEncodingKey: UTF-8
LanguageLocaleKey: en_US
ProfileId:
Salesforce.ProfileId: Identity User
21 changes: 21 additions & 0 deletions tests/cassettes/TestSalesforcePlugin.test_profile_id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
interactions:
- request:
body: null
headers:
Request-Headers:
- Elided
method: GET
uri: https://orgname.my.salesforce.com/services/data/v50.0/query/?q=select+Id+from+Profile+where+Name%3D%27Identity+User%27
response:
body:
string: "{\n \"totalSize\" : 1,\n \"done\" : true,\n \"records\" : [ {\n
\ \"attributes\" : {\n \"type\" : \"Profile\",\n \"url\" : \"/services/data/v50.0/sobjects/Profile/00e0R000000yGOcQAM\"\n
\ },\n \"Id\" : \"00e0R000000yGOcQAM\"\n } ]\n}"
headers:
Content-Type:
- application/json;charset=UTF-8
Response-Headers: SF-Elided
status:
code: 200
message: OK
version: 1
19 changes: 19 additions & 0 deletions tests/test_salesforce_gen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from base64 import b64decode
from io import StringIO

from snowfakery import generate_data
from tests.test_with_cci import skip_if_cumulusci_missing

import pytest


class TestSalesforceGen:
Expand All @@ -11,3 +15,18 @@ def test_content_version(self, generated_rows):
rawdata = b64decode(b64data)
assert rawdata.startswith(b"%PDF-1.3")
assert b"Helvetica" in rawdata


class TestSalesforcePlugin:
@skip_if_cumulusci_missing
@pytest.mark.vcr()
def test_profile_id(self, generated_rows, org_config):
yaml = """
- plugin: snowfakery.standard_plugins.Salesforce
- object: foo
fields:
ProfileId:
Salesforce.ProfileId: Identity User
"""
generate_data(StringIO(yaml), plugin_options={"org_name": org_config.name})
assert generated_rows.table_values("foo", 0, "ProfileId").startswith("00e")

0 comments on commit 117cfc8

Please sign in to comment.