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

feat: save namespacePrefix in auth file #908

Merged
merged 3 commits into from
Aug 3, 2023
Merged

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Aug 1, 2023

What does this PR do?

Save the namespace prefix of an org in its auth file.
When creating an instance of AuthInfo, sfdx-core will query the namespace prefix of an org and save it as namespacePrefix.

Organization object:
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_organization.htm

What issues does this PR fix or reference?

@W-12709731@
@W-12709714@

);

if (namespacePrefix) {
authConfig.namespacePrefix = namespacePrefix;
Copy link
Member Author

Choose a reason for hiding this comment

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

getNamespacePrefix will return undefined if an org doesn't have a namespace prefix we just set it if there's one.

const authInfo = await AuthInfo.create({ username: testOrg.username });
// @ts-expect-error because private method
expect(await authInfo.getNamespacePrefix(testOrg.instanceUrl, testOrg.accessToken)).to.be.undefined;
expect(authInfo.getFields().namespacePrefix).to.be.undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

this test verifies that getNamespacePrefix returns undefined instead of an empty string to ensure we never end up with namespacePrefix: "" in an auth file.

match({
url: `${testOrg.instanceUrl}//services/data/v51.0/query?q=Select%20Namespaceprefix%20FROM%20Organization`,
})
)
Copy link
Member Author

Choose a reason for hiding this comment

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

use sinon matcher to only stub the namespace query:
https://sinonjs.org/releases/latest/matchers/

@shetzel
Copy link
Contributor

shetzel commented Aug 3, 2023

QA: linked this branch to plugin-auth, then authed an org that had a namespace. I see it in the auth file and it's returned with sf org list --json

@shetzel shetzel merged commit 3738937 into main Aug 3, 2023
31 checks passed
@shetzel shetzel deleted the cd/save-namespace-auth-info branch August 3, 2023 19:34
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.

3 participants