public async Task WhenDisablingDca_ThenRefreshUpdatesStateToDisabled() { // Enable DCA. var settings = this.settingsRepository.GetSettings(); settings.IsDeviceCertificateAuthenticationEnabled.BoolValue = true; this.settingsRepository.SetSettings(settings); var certificateStore = new Mock <ICertificateStoreAdapter>(); certificateStore.Setup(s => s.ListUserCertitficates( It.IsAny <string>(), It.IsAny <string>())) .Returns(new[] { ExampleCertificate }); var enrollment = await SecureConnectEnrollment.GetEnrollmentAsync( certificateStore.Object, this.settingsRepository, SampleUserId); Assert.AreEqual(DeviceEnrollmentState.Enrolled, enrollment.State); Assert.IsNotNull(enrollment.Certificate); Assert.AreEqual(ExampleCertitficateSubject, enrollment.Certificate.Subject); // Disable DCA. settings.IsDeviceCertificateAuthenticationEnabled.BoolValue = false; this.settingsRepository.SetSettings(settings); await enrollment.RefreshAsync(SampleUserId); Assert.AreEqual(DeviceEnrollmentState.Disabled, enrollment.State); Assert.IsNull(enrollment.Certificate); }
public async Task WhenDcaIsDisabledInSettings_ThenStateIsNotInstalled() { // Disable DCA. var settings = this.settingsRepository.GetSettings(); settings.IsDeviceCertificateAuthenticationEnabled.BoolValue = false; this.settingsRepository.SetSettings(settings); var certificateStore = new Mock <ICertificateStoreAdapter>(); var enrollment = await SecureConnectEnrollment.GetEnrollmentAsync( certificateStore.Object, this.settingsRepository, SampleUserId); Assert.AreEqual(DeviceEnrollmentState.Disabled, enrollment.State); Assert.IsNull(enrollment.Certificate); certificateStore.Verify(s => s.ListUserCertitficates( It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public async Task WhenDcaEnabledButNoCertificateInStore_ThenStateIsNotEnrolled() { // Enable DCA. var settings = this.settingsRepository.GetSettings(); settings.IsDeviceCertificateAuthenticationEnabled.BoolValue = true; this.settingsRepository.SetSettings(settings); var certificateStore = new Mock <ICertificateStoreAdapter>(); certificateStore.Setup(s => s.ListUserCertitficates( It.IsAny <string>(), It.IsAny <string>())) .Returns(Enumerable.Empty <X509Certificate2>()); var enrollment = await SecureConnectEnrollment.GetEnrollmentAsync( certificateStore.Object, this.settingsRepository, SampleUserId); Assert.AreEqual(DeviceEnrollmentState.NotEnrolled, enrollment.State); Assert.IsNull(enrollment.Certificate); }