public async Task ensure_order_sync_get_returns_jobject()
        {
            mockOrderCloudClient.Me.GetAsync().ReturnsForAnyArgs(new MeUser()
            {
                Active   = true,
                Username = "******",
                ID       = "oliver",
                Email    = "*****@*****.**",
                Supplier = new MeSupplier()
                {
                    ID = "xxx_bad_xxx"
                },
                AvailableRoles = new List <string>()
                {
                    "FullAccess"
                }
            });

            var functionToken = new OrderCloudIntegrationsFunctionToken(Substitute.For <AppSettings>());
            var verifiedUser  = await functionToken.Authorize(mockHttpRequest, new[] { ApiRole.OrderAdmin }, mockOrderCloudClient);

            var command = new SupplierSyncCommand(Substitute.For <AppSettings>());

            Assert.ThrowsAsync <MissingMethodException>(async() => await command.GetOrderAsync("ID", verifiedUser));
        }
Exemplo n.º 2
0
        public void inactive_user_throws_exception()
        {
            mockOrderCloudClient.Me.GetAsync().ReturnsForAnyArgs(new MeUser()
            {
                Active = false
            });

            var functionToken = new OrderCloudIntegrationsFunctionToken(Substitute.For <AppSettings>());

            Assert.ThrowsAsync <Exception>(async() => await functionToken.Authorize(mockHttpRequest, new[] { ApiRole.OrderAdmin }, mockOrderCloudClient));
        }
Exemplo n.º 3
0
        public async Task valid_token_returns_user(MeUser user)
        {
            mockOrderCloudClient.Me.GetAsync().ReturnsForAnyArgs(user);
            var functionToken = new OrderCloudIntegrationsFunctionToken(Substitute.For <AppSettings>());
            var verifiedUser  = await functionToken.Authorize(mockHttpRequest, new[] { ApiRole.OrderAdmin }, mockOrderCloudClient);

            Assert.IsTrue(user.ID == verifiedUser.ID);
            if (user.Supplier != null)
            {
                Assert.IsTrue(user.Supplier.ID == verifiedUser.Supplier.ID);
            }
            if (user.Buyer != null)
            {
                Assert.IsTrue(user.Buyer.ID == verifiedUser.Buyer.ID);
            }
            Assert.IsTrue(user.Email == verifiedUser.Email);
            Assert.IsTrue(user.Username == verifiedUser.Username);
        }