-
Notifications
You must be signed in to change notification settings - Fork 70
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
test: add field auth e2e userpools provider #2156
test: add field auth e2e userpools provider #2156
Conversation
import { ImportedRDSType } from '@aws-amplify/graphql-transformer-core'; | ||
import { convertToDBSpecificGraphQLString, generateDDL } from '../../rds-v2-test-utils'; | ||
|
||
export const schema = (engine: ImportedRDSType): string => ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is engine
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's certainly is not used here, removed.
input: any, | ||
selectionSet?: string, | ||
isCompleteQuery = true, | ||
errorPolicy?: ErrorPolicy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not assign a default here like you do for the preceding and following args?
selectionSet?: string, | ||
operation?: string, | ||
isCompleteQuery = true, | ||
errorPolicy?: ErrorPolicy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as above, why not default it?
if (errors && errors.length > 0) { | ||
expect(result.errors).toBeDefined(); | ||
expect(result.errors).toHaveLength(errors.length); | ||
result.errors?.forEach((error: any, index: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If order doesn't matter, would it be less brittle to use arrayContaining
matcher?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Order shouldn't matter here much. Updated.
async () => await user1TodoHelper.delete(`delete${modelName}`, { id: todo['id'] }, user1CreateAllowedSet), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(expectedOperationError(`delete${modelName}`, 'Mutation')); | ||
|
||
// user2 can listen to updates on the non-protected fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we test that user2 can also listen for updates to ownersContent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes in the onUpdate
subscription since that field only allows updates.
packages/amplify-e2e-tests/src/rds-v2-tests-common/rds-auth-userpool-fields.ts
Show resolved
Hide resolved
packages/amplify-e2e-tests/src/rds-v2-tests-common/rds-auth-userpool-fields.ts
Show resolved
Hide resolved
packages/amplify-e2e-tests/src/rds-v2-tests-common/rds-auth-userpool-fields.ts
Show resolved
Hide resolved
packages/amplify-e2e-tests/src/rds-v2-tests-common/rds-auth-userpool-fields.ts
Show resolved
Hide resolved
packages/amplify-e2e-tests/src/rds-v2-tests-common/rds-auth-userpool-fields.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Reminder: the last few cases are skipped will be addressed later.
test('Private model auth and allowed field operations', async () => { | ||
const modelName = 'TodoPrivateContentVarious'; | ||
const user1ModelOperationHelpers = createModelOperationHelpers(appSyncClients[userPoolProvider][userName1], schema); | ||
const user2ModelOperationHelpers = createModelOperationHelpers(appSyncClients[userPoolProvider][userName2], schema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the two user model operation helpers can be moved to the common part before the test suits as the outcome is the same
Description of changes
userpools
provider. The tests cover combinations ofprivate
, defaultowner
, customowner
field, custom array ofowners
. More complex cases like multiple auth rules and relationships are tracked separately.CDK / CloudFormation Parameters Changed
Issue #, if available
Description of how you validated changes
Unit test for removed check.
Ran added E2Es on CI.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.