Exemple #1
0
        public async Task Delete_When_Not_Authorized()
        {
            var assertDatabase = await RfidDatabaseAssert.CreateAsync();

            var userRM = Examples.Administrator();
            var tagRM  = Examples.Tag();

            await RfidHttpClient.RegisterUserAsync(userRM);

            using (var authHttpResponse = await RfidHttpClient.GenerateAuthTokenAsync(userRM))
            {
                var authToken = await AuthTokenHelper.FromHttpResponseMessageAsync(authHttpResponse);

                var token = await authToken.GetTokenAsync();

                using (var registerTagHttpResponse = await RfidHttpClient.RegisterTagAsync(tagRM, token))
                {
                    RfidAssert.AssertHttpResponse(registerTagHttpResponse, System.Net.HttpStatusCode.OK);

                    using (var activateHttpResponse = await RfidHttpClient.DeleteTagAsync(tagRM.Number, null))
                    {
                        RfidAssert.AssertHttpResponse(activateHttpResponse, System.Net.HttpStatusCode.Unauthorized);
                    }
                }
            }

            var tagId = await RfidDatabase.GetTagIdByNumberAsync(tagRM.Number);

            await assertDatabase.AssertCntAsync(userRM, tagRM);

            await assertDatabase.AssertStateAsync("[access_control].[Tags]", tagId, new { Id = tagId, IsActive = true, IsDeleted = false });
        }
Exemple #2
0
        public async Task Delete_When_Tag_Does_Not_Exists()
        {
            var assertDatabase = await RfidDatabaseAssert.CreateAsync();

            var userRM = Examples.Administrator();

            await RfidHttpClient.RegisterUserAsync(userRM);

            using (var authHttpResponse = await RfidHttpClient.GenerateAuthTokenAsync(userRM))
            {
                var authToken = await AuthTokenHelper.FromHttpResponseMessageAsync(authHttpResponse);

                var token = await authToken.GetTokenAsync();

                using (var activateHttpResponse = await RfidHttpClient.DeleteTagAsync("unknown", token))
                {
                    RfidAssert.AssertHttpResponse(activateHttpResponse, System.Net.HttpStatusCode.NotFound);
                }
            }

            await assertDatabase.AssertCntAsync(userRM);
        }