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

fix(editor): Issue showing Auth2 callback section when all properties are overriden #8999

Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions cypress/e2e/2-credentials.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,29 @@ describe('Credentials', () => {
.find('input')
.should('have.value', NEW_QUERY_AUTH_ACCOUNT_NAME);
});

it('should not show OAuth redirect URL section when OAuth2 credentials are overridden', () => {
cy.intercept('/types/credentials.json', { middleware: true }, (req) => {
req.headers['cache-control'] = 'no-cache, no-store';

req.on('response', (res) => {
const credentials = res.body || [];

const index = credentials.findIndex((c) => c.name === 'slackOAuth2Api');

credentials[index] = {
...credentials[index],
__overwrittenProperties: ['clientId', 'clientSecret'],
};
});
});

workflowPage.actions.visit(true);
workflowPage.actions.addNodeToCanvas('Slack');
workflowPage.actions.openNode('Slack');
workflowPage.getters.nodeCredentialsSelect().click();
getVisibleSelect().find('li').last().click();
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
nodeDetailsView.getters.copyInput().should('not.exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
/>

<CopyInput
v-if="isOAuthType && credentialProperties.length"
v-if="isOAuthType && !allOAuth2BasePropertiesOverridden"
RicardoE105 marked this conversation as resolved.
Show resolved Hide resolved
:label="$locale.baseText('credentialEdit.credentialConfig.oAuthRedirectUrl')"
:value="oAuthCallbackUrl"
:copy-button-text="$locale.baseText('credentialEdit.credentialConfig.clickToCopy')"
Expand Down Expand Up @@ -204,6 +204,9 @@ export default defineComponent({
isOAuthType: {
type: Boolean,
},
allOAuth2BasePropertiesOverridden: {
type: Boolean,
},
isOAuthConnected: {
type: Boolean,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
:parent-types="parentTypes"
:required-properties-filled="requiredPropertiesFilled"
:credential-permissions="credentialPermissions"
:all-o-auth2-base-properties-overridden="allOAuth2BasePropertiesOverridden"
:mode="mode"
:selected-credential="selectedCredential"
:show-auth-type-selector="requiredCredentials"
Expand Down Expand Up @@ -427,6 +428,15 @@ export default defineComponent({
this.parentTypes.includes('oAuth1Api'))
);
},
allOAuth2BasePropertiesOverridden() {
if (this.credentialType?.__overwrittenProperties) {
return (
this.credentialType.__overwrittenProperties.includes('clientId') &&
this.credentialType.__overwrittenProperties.includes('clientSecret')
);
}
return false;
},
isOAuthConnected(): boolean {
return this.isOAuthType && !!this.credentialData.oauthTokenData;
},
Expand All @@ -435,7 +445,7 @@ export default defineComponent({
return [];
}

return this.credentialType.properties.filter((propertyData: INodeProperties) => {
const properties = this.credentialType.properties.filter((propertyData: INodeProperties) => {
if (!this.displayCredentialParameter(propertyData)) {
return false;
}
Expand All @@ -444,6 +454,17 @@ export default defineComponent({
!this.credentialType!.__overwrittenProperties.includes(propertyData.name)
);
});

/**
* If after all credentials overrides are applied only "notice"
* properties are left, do not return them. This will avoid
* showing notices that refer to a property that was overridden.
*/
if (properties.every((p) => p.type === 'notice')) {
return [];
}

return properties;
},
requiredPropertiesFilled(): boolean {
for (const property of this.credentialProperties) {
Expand Down
Loading