public async Task Activate_When_Not_Authorized() { var assertDatabase = await RfidDatabaseAssert.CreateAsync(); var userRM = Examples.Administrator(); var accessPointRM = Examples.AccessPoint(); var accessPointId = 0; await RfidHttpClient.RegisterUserAsync(userRM); using (var authTokenResponse = await RfidHttpClient.GenerateAuthTokenAsync(userRM)) { var authToken = await AuthTokenHelper.FromHttpResponseMessageAsync(authTokenResponse); var token = await authToken.GetTokenAsync(); using (var registerAccessPointResponse = await RfidHttpClient.RegisterAccessPointAsync(accessPointRM, token)) { accessPointId = await RfidDatabase.GetAccessPointIdBySerialNumberAsync(accessPointRM.SerialNumber); await RfidDatabase.DeActivateAccessPointAsync(accessPointId); using (var activateAccessPointResponse = await RfidHttpClient.ActivateAccessPointAsync(accessPointRM.SerialNumber, "unknown")) { RfidAssert.AssertHttpResponse(activateAccessPointResponse, System.Net.HttpStatusCode.Unauthorized); } } } await assertDatabase.AssertCntAsync(userRM, accessPointRM); await assertDatabase.AssertStateAsync("access_control.AccessPoints", accessPointId, new { Id = accessPointId, IsActive = false }); }
public async Task Activate_When_Several() { var assertDatabase = await RfidDatabaseAssert.CreateAsync(); var userRM = Examples.Administrator(); var faccessPointRM = Examples.AccessPoint("test1"); var saccessPointRM = Examples.AccessPoint("test2"); var faccessPointId = 0; var saccessPointId = 0; await RfidHttpClient.RegisterUserAsync(userRM); using (var authTokenResponse = await RfidHttpClient.GenerateAuthTokenAsync(userRM)) { var authToken = await AuthTokenHelper.FromHttpResponseMessageAsync(authTokenResponse); var token = await authToken.GetTokenAsync(); using (var fregisterAccessPointResponse = await RfidHttpClient.RegisterAccessPointAsync(faccessPointRM, token)) using (var sregisterAccessPointResponse = await RfidHttpClient.RegisterAccessPointAsync(saccessPointRM, token)) { faccessPointId = await RfidDatabase.GetAccessPointIdBySerialNumberAsync(faccessPointRM.SerialNumber); saccessPointId = await RfidDatabase.GetAccessPointIdBySerialNumberAsync(saccessPointRM.SerialNumber); await RfidDatabase.DeActivateAccessPointAsync(faccessPointId); await RfidDatabase.DeActivateAccessPointAsync(saccessPointId); using (var activateAccessPointResponse = await RfidHttpClient.ActivateAccessPointAsync(faccessPointRM.SerialNumber, token)) { RfidAssert.AssertHttpResponse(activateAccessPointResponse, System.Net.HttpStatusCode.OK); } } } await assertDatabase.AssertCntAsync(userRM, faccessPointRM, saccessPointRM); await assertDatabase.AssertStateAsync("access_control.AccessPoints", faccessPointId, new { Id = faccessPointId, IsActive = true }); await assertDatabase.AssertStateAsync("access_control.AccessPoints", saccessPointId, new { Id = saccessPointId, IsActive = false }); }