diff --git a/auth0_flutter/test/web/extensions/user_profile_extension_test.dart b/auth0_flutter/test/web/extensions/user_profile_extension_test.dart index 89f15aee..c81cb39a 100644 --- a/auth0_flutter/test/web/extensions/user_profile_extension_test.dart +++ b/auth0_flutter/test/web/extensions/user_profile_extension_test.dart @@ -128,6 +128,61 @@ void main() { expect(result.customClaims, customClaims); }); + test('creates UserProfile from claims with stringified email_verified', + () async { + const Map claims = { + ...requiredValues, + PublicClaims.name: 'John Alexander Doe', + PublicClaims.givenName: 'John', + PublicClaims.familyName: 'Doe', + PublicClaims.middleName: 'Alexander', + PublicClaims.nickname: 'johnny', + PublicClaims.preferredUsername: 'johnnyD', + PublicClaims.profile: 'https://example.com/profile', + PublicClaims.picture: 'https://example.com/picture.png', + PublicClaims.website: 'https://example.com', + PublicClaims.email: 'john.doe@example.com', + PublicClaims.emailVerified: 'true', + PublicClaims.gender: 'male', + PublicClaims.birthdate: '01-01-2000', + PublicClaims.zoneinfo: 'America/Chicago', + PublicClaims.locale: 'en-US', + PublicClaims.phoneNumber: '111111111', + PublicClaims.phoneNumberVerified: true, + PublicClaims.address: {'street': '1 Foo St', 'zip_code': '11111-1111'}, + PublicClaims.updatedAt: '2023-02-28T15:08:56+00:00', + 'foo': 'bar' + }; + + final result = UserProfileExtension.fromClaims(claims); + + expect(result.name, claims[PublicClaims.name]); + expect(result.givenName, claims[PublicClaims.givenName]); + expect(result.familyName, claims[PublicClaims.familyName]); + expect(result.middleName, claims[PublicClaims.middleName]); + expect(result.nickname, claims[PublicClaims.nickname]); + expect(result.preferredUsername, claims[PublicClaims.preferredUsername]); + expect( + result.profileUrl, Uri.parse(claims[PublicClaims.profile] as String)); + expect( + result.pictureUrl, Uri.parse(claims[PublicClaims.picture] as String)); + expect( + result.websiteUrl, Uri.parse(claims[PublicClaims.website] as String)); + expect(result.email, claims[PublicClaims.email]); + expect(result.isEmailVerified, claims[PublicClaims.emailVerified]); + expect(result.gender, claims[PublicClaims.gender]); + expect(result.birthdate, claims[PublicClaims.birthdate]); + expect(result.zoneinfo, claims[PublicClaims.zoneinfo]); + expect(result.locale, claims[PublicClaims.locale]); + expect(result.phoneNumber, claims[PublicClaims.phoneNumber]); + expect(result.isPhoneNumberVerified, + claims[PublicClaims.phoneNumberVerified]); + expect(result.address, claims[PublicClaims.address]); + expect(result.updatedAt, + DateTime.parse(claims[PublicClaims.updatedAt] as String)); + expect(result.customClaims?['foo'], claims['foo']); + }); + test('throws exception with invalid profile URL', () async { const Map claims = { ...requiredValues,