Skip to content

Commit

Permalink
Add test to StrapiTokenApi credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
elsmr committed Aug 30, 2023
1 parent 1840c79 commit a65a83b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/nodes-base/credentials/StrapiTokenApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class StrapiTokenApi implements ICredentialType {
name = 'strapiTokenApi';
Expand Down Expand Up @@ -51,4 +56,22 @@ export class StrapiTokenApi implements ICredentialType {
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.url}}',
url: '={{$credentials.apiVersion === "v3" ? "/users/count" : "/api/users/count"}}',
ignoreHttpStatusErrors: true,
},
rules: [
{
type: 'responseSuccessBody',
properties: {
key: 'error.name',
value: 'UnauthorizedError',
message: 'Invalid API token',
},
},
],
};
}

0 comments on commit a65a83b

Please sign in to comment.