public async Task TestAuthFailureAsync()
        {
            var invalidResponse = new JObject();

            invalidResponse.Add("code", IntuneScepServiceException.ErrorCode.ChallengeDecryptionError.ToString());
            invalidResponse.Add("errorDescription", "");

            var authContextMock = new Mock <IAuthenticationContext>();

            authContextMock.Setup(foo => foo.AcquireTokenAsync(
                                      It.IsAny <string>(), It.IsAny <ClientCredential>())
                                  ).Throws(
                new AdalServiceException("", "")
                );

            var locationProviderMock = new Mock <IIntuneServiceLocationProvider>();

            locationProviderMock.Setup(foo => foo.GetServiceEndpointAsync(Microsoft.Intune.IntuneScepValidator.VALIDATION_SERVICE_NAME))
            .Returns(Task.FromResult <string>(@"http://localhost/"));


            var adalClient   = new AdalClient(configProperties);
            var intuneClient = new IntuneClient(configProperties, adalClient: adalClient, locationProvider: locationProviderMock.Object);
            var scepClient   = new Microsoft.Intune.IntuneScepValidator(configProperties, intuneClient: intuneClient);

            Guid   transactionId = Guid.NewGuid();
            string csr           = "testing";

            await scepClient.SendFailureNotificationAsync(transactionId.ToString(), csr, 1, "description");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Invoke wipe operation for the user's device
        /// </summary>
        private void InvokeDeviceWipeOperation()
        {
            this.ConfirmAction(
                this.Force,
                string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.InvokeDeviceWipe_ActionMessage,
                    this.DeviceName,
                    this.Name),
                string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.InvokeDeviceWipe_ProcessMessage,
                    this.DeviceName,
                    this.Name),
                this.Name,
                () =>
            {
                var result =
                    IntuneClient.WipeMAMUserDeviceWithHttpMessagesAsync(
                        this.AsuHostName,
                        this.Name,
                        this.DeviceName)
                    .GetAwaiter()
                    .GetResult();

                this.WriteObject(result.Body);
            });
        }
Ejemplo n.º 3
0
        public async Task TestURLChangesAsync()
        {
            var invalidResponse = new JObject();

            invalidResponse.Add("code", IntuneScepServiceException.ErrorCode.ChallengeDecryptionError.ToString());
            invalidResponse.Add("errorDescription", "");

            var locationProviderMock = new Mock <IIntuneServiceLocationProvider>();

            locationProviderMock.Setup(foo => foo.GetServiceEndpointAsync(IntuneScepValidator.VALIDATION_SERVICE_NAME))
            .Returns(Task.FromResult <string>(@"http://localhost/"));

            var httpClientMock = new Mock <IHttpClient>();

            httpClientMock.Setup(foo => foo.PostAsync(It.IsAny <string>(), It.IsAny <HttpContent>()))
            .Throws(new HttpRequestException());

            var authClient   = new MsalClient(configProperties);
            var intuneClient = new IntuneClient(configProperties, authClient: authClient, locationProvider: locationProviderMock.Object, httpClient: httpClientMock.Object);
            var scepClient   = new Microsoft.Intune.IntuneScepValidator(configProperties, intuneClient: intuneClient);

            Guid   transactionId = Guid.NewGuid();
            string csr           = "testing";

            await scepClient.SendFailureNotificationAsync(transactionId.ToString(), csr, 1, "description");

            locationProviderMock.Verify(foo => foo.GetServiceEndpointAsync(IntuneScepValidator.VALIDATION_SERVICE_NAME), Times.Once);
            locationProviderMock.Verify(foo => foo.Clear(), Times.Once);
        }
        /// <summary>
        /// Get MAM summary status
        /// </summary>
        private void GetMAMDefaultStatus()
        {
            var result = IntuneClient.GetMAMStatuses(this.AsuHostName);

            this.WriteObject(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get MAM flagged user by name
        /// </summary>
        private void GetMAMFlaggedUserByName()
        {
            var result = IntuneClient.GetMAMFlaggedUserByName(this.AsuHostName, Name);

            this.WriteObject(result);
        }