Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,56 @@ describe('AppSync Dart Visitor', () => {
const generatedCode = visitor.generate();
expect(generatedCode).toMatchSnapshot();
})

it('should map identityPool provider to IAM in generated Dart code', () => {
const schema = /* GraphQL */ `
type IdentityPoolModel
@model
@auth(
rules: [
{ allow: private, provider: "identityPool" }
{ allow: owner }
]
) {
id: ID!
name: String!
}
`;

const visitor = getVisitor({
schema,
selectedType: 'IdentityPoolModel',
isTimestampFieldsAdded: true,
});

const generatedCode = visitor.generate();
expect(generatedCode).toContain('AuthRuleProvider.IAM');
expect(generatedCode).not.toContain('AuthRuleProvider.IDENTITYPOOL');
});

it('should map iam provider to IAM in generated Dart code (unchanged behavior)', () => {
const schema = /* GraphQL */ `
type IamModel
@model
@auth(
rules: [
{ allow: private, provider: "iam" }
]
) {
id: ID!
name: String!
}
`;

const visitor = getVisitor({
schema,
selectedType: 'IamModel',
isTimestampFieldsAdded: true,
});

const generatedCode = visitor.generate();
expect(generatedCode).toContain('AuthRuleProvider.IAM');
});
});

describe('Model with Connection Directive', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ export class AppSyncModelDartVisitor<
return '';
}
if (rule.provider) {
authRule.push(`provider: ${DART_AMPLIFY_CORE_TYPES.AuthRuleProvider}.${rule.provider.toUpperCase()}`);
const provider = (rule.provider as string) === 'identityPool' ? 'iam' : rule.provider;
authRule.push(`provider: ${DART_AMPLIFY_CORE_TYPES.AuthRuleProvider}.${provider.toUpperCase()}`);
}
authRule.push(
[
Expand Down
Loading