Esempio n. 1
0
        public void Submit_Authorization_Success()
        {
            TestAuthAttribute.Reset();

            Product product = new Product {
                ProductID = 1, ProductName = "Choco Wafers"
            };

            ChangeSetEntry[] changeSet = new ChangeSetEntry[] {
                new ChangeSetEntry {
                    Id = 1, Entity = product, Operation = ChangeOperation.Update
                }
            };

            ChangeSetEntry[] resultChangeSet = this.ExecuteSubmit("http://testhost/TestAuth/Submit", "TestAuth", changeSet);
            Assert.Equal(1, resultChangeSet.Length);
            Assert.True(TestAuthAttribute.Log.SequenceEqual(new string[] { "Global", "Class", "SubmitMethod", "UserMethod" }));
        }
Esempio n. 2
0
        public void Submit_Authorization_Fail_Global()
        {
            TestAuthAttribute.Reset();

            Product product = new Product {
                ProductID = 1, ProductName = "Choco Wafers"
            };

            ChangeSetEntry[] changeSet = new ChangeSetEntry[] {
                new ChangeSetEntry {
                    Id = 1, Entity = product, Operation = ChangeOperation.Update
                }
            };

            TestAuthAttribute.FailLevel = "Global";
            HttpResponseMessage response = this.ExecuteSelfHostRequest("http://testhost/TestAuth/Submit", "TestAuth", changeSet);

            Assert.True(TestAuthAttribute.Log.SequenceEqual(new string[] { "Global" }));
            Assert.Equal("Not Authorized", response.ReasonPhrase);
            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }