Ejemplo n.º 1
0
        public Fakes()
        {
            _users = Get <User>();
            _packageRegistrations = Get <PackageRegistration>();

            var key = 39;
            var credentialBuilder = new CredentialBuilder();

            ApiKeyV3PlaintextValue = "889e180e-335c-491a-ac26-e83c4bd31d87";

            User = new User("testUser")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                Credentials  = new List <Credential>
                {
                    credentialBuilder.CreatePasswordCredential(Password),
                    TestCredentialHelper.CreateV1ApiKey(Guid.Parse("669e180e-335c-491a-ac26-e83c4bd31d65"),
                                                        ExpirationForApiKeyV1),
                    TestCredentialHelper.CreateV2ApiKey(Guid.Parse("779e180e-335c-491a-ac26-e83c4bd31d87"),
                                                        ExpirationForApiKeyV1).WithDefaultScopes(),
                    TestCredentialHelper.CreateV3ApiKey(Guid.Parse(ApiKeyV3PlaintextValue),
                                                        ExpirationForApiKeyV1).WithDefaultScopes(),
                    TestCredentialHelper.CreateV4ApiKey(null, out string apiKeyV4PlaintextValue).WithDefaultScopes(),
                    TestCredentialHelper.CreateV2VerificationApiKey(Guid.Parse("b0c51551-823f-4701-8496-43980b4b3913")),
                    TestCredentialHelper.CreateExternalCredential("abc")
                },
Ejemplo n.º 2
0
        public Fakes()
        {
            _users = Get <User>();
            _packageRegistrations = Get <PackageRegistration>();

            var key = 39;
            var credentialBuilder = new CredentialBuilder();

            User = new User("testUser")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                Credentials  = new List <Credential>
                {
                    credentialBuilder.CreatePasswordCredential(Password),
                    TestCredentialHelper.CreateV1ApiKey(Guid.Parse("669e180e-335c-491a-ac26-e83c4bd31d65"),
                                                        ExpirationForApiKeyV1),
                    TestCredentialHelper.CreateV2ApiKey(Guid.Parse("779e180e-335c-491a-ac26-e83c4bd31d87"),
                                                        ExpirationForApiKeyV1).WithDefaultScopes(),
                    TestCredentialHelper.CreateV4ApiKey(null, out string apiKeyV4PlaintextValue).WithDefaultScopes(),
                    TestCredentialHelper.CreateV2VerificationApiKey(Guid.Parse("b0c51551-823f-4701-8496-43980b4b3913")),
                    TestCredentialHelper.CreateExternalCredential("abc")
                }
            };

            ApiKeyV4PlaintextValue = apiKeyV4PlaintextValue;

            Organization = new Organization("testOrganization")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                // invalid credentials for testing authentication constraints
                Credentials = new List <Credential>
                {
                    credentialBuilder.CreatePasswordCredential(Password)
                }
            };

            CreateOrganizationUsers(ref key, credentialBuilder, "", out var organization, out var organizationAdmin, out var organizationCollaborator);
            Organization             = organization;
            OrganizationAdmin        = organizationAdmin;
            OrganizationCollaborator = organizationCollaborator;

            CreateOrganizationUsers(ref key, credentialBuilder, "Owner", out var organizationOwner, out var organizationAdminOwner, out var organizationCollaboratorOwner);
            OrganizationOwner             = organizationOwner;
            OrganizationOwnerAdmin        = organizationAdminOwner;
            OrganizationOwnerCollaborator = organizationCollaboratorOwner;

            Pbkdf2User = new User("testPbkdf2User")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                Credentials  = new List <Credential>
                {
                    TestCredentialHelper.CreatePbkdf2Password(Password),
                    TestCredentialHelper.CreateV1ApiKey(Guid.Parse("519e180e-335c-491a-ac26-e83c4bd31d65"),
                                                        ExpirationForApiKeyV1)
                }
            };

            ShaUser = new User("testShaUser")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                Credentials  = new List <Credential>
                {
                    TestCredentialHelper.CreateSha1Password(Password),
                    TestCredentialHelper.CreateV1ApiKey(Guid.Parse("b9704a41-4107-4cd2-bcfa-70d84e021ab2"),
                                                        ExpirationForApiKeyV1)
                }
            };

            Admin = new User("testAdmin")
            {
                Key          = key++,
                EmailAddress = "*****@*****.**",
                Credentials  = new List <Credential> {
                    TestCredentialHelper.CreatePbkdf2Password(Password)
                },
                Roles = new List <Role> {
                    new Role {
                        Name = Constants.AdminRoleName
                    }
                }
            };

            Owner = new User("testPackageOwner")
            {
                Key         = key++,
                Credentials = new List <Credential> {
                    TestCredentialHelper.CreatePbkdf2Password(Password)
                },
                EmailAddress = "*****@*****.**" //package owners need confirmed email addresses, obviously.
            };

            Package = new PackageRegistration
            {
                Id     = "FakePackage",
                Owners = new List <User> {
                    Owner, OrganizationOwner
                },
            };
            Package.Packages = new List <Package>
            {
                new Package {
                    Version = "1.0", PackageRegistration = Package
                },
                new Package {
                    Version = "2.0", PackageRegistration = Package
                }
            };
        }