コード例 #1
0
        public void GetAppSettingsUnrecognizedApiKeyThrows()
        {
            IAnonymous     client             = this.GetAnonymousClient();
            string         unrecognizedApiKey = Guid.NewGuid().ToString();
            AspenException exception          = Assert.Throws <AspenException>(() => client.Settings.GetAppSettings(unrecognizedApiKey));

            Assert.That(exception.EventId, Is.EqualTo("20005"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("Identificador de ApiKey no válido para la cabecera personalizada 'X-PRO-Auth-App'", exception.Message);
        }
コード例 #2
0
        public void GetAppSettingsUsingAutonomousApiKeyThrows()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();
            string         autonomousApiKey = AutonomousAppIdentity.Master.ApiKey;
            AspenException exception        = Assert.Throws <AspenException>(() => client.Settings.GetAppSettings(autonomousApiKey));

            Assert.That(exception.EventId, Is.EqualTo("1000478"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
            StringAssert.IsMatch("ApiKey no tiene permisos para realizar la operación. Alcance requerido: 'Delegated'", exception.Message);
        }
コード例 #3
0
        public void GetAppSettingsWorks()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();
            string         recognizedApiKey = DelegatedAppIdentity.Master.ApiKey;
            AppMovSettings appMovSettings   = client.Settings.GetAppSettings(recognizedApiKey);

            CollectionAssert.IsNotEmpty(appMovSettings);
            Assert.That(appMovSettings.GetKeyValue <bool>("enableBiometricAuth:iOS", true), Is.True);
            Assert.That(appMovSettings.GetKeyValue("enableBiometricAuth:Android", true), Is.True);
            Assert.That(appMovSettings.GetKeyValue("enableRememberUsernameLogin", true), Is.True);
        }
コード例 #4
0
        public void GetSettingsAsynchronouslyWorks()
        {
            IAnonymous client = this.GetAnonymousClient();

            IList <DocTypeInfo> docTypes    = Enumerable.Empty <DocTypeInfo>().ToList();
            string         recognizedApiKey = DelegatedAppIdentity.Master.ApiKey;
            AppMovSettings appMovSettings   = new AppMovSettings();

            Assert.DoesNotThrowAsync(async() => docTypes       = await client.Settings.GetDefaultDocTypesAsync());
            Assert.DoesNotThrowAsync(async() => appMovSettings = await client.Settings.GetAppSettingsAsync(recognizedApiKey));
            CollectionAssert.IsNotEmpty(docTypes);
            CollectionAssert.IsNotEmpty(appMovSettings);
        }
コード例 #5
0
        public void GetAppSettingsFromCacheWorks()
        {
            IAnonymous client           = this.GetAnonymousClient(CachePolicy.CacheIfAvailable);
            string     recognizedApiKey = DelegatedAppIdentity.Master.ApiKey;

            Assert.DoesNotThrow(() => client.Settings.GetAppSettings(recognizedApiKey));
            for (int index = 1; index <= 10; index++)
            {
                Stopwatch      watch          = Stopwatch.StartNew();
                AppMovSettings appMovSettings = client.Settings.GetAppSettings(recognizedApiKey);
                watch.Stop();
                CollectionAssert.IsNotEmpty(appMovSettings);
                Assert.That(watch.Elapsed, Is.LessThanOrEqualTo(TimeSpan.FromMilliseconds(10)));
            }
        }
コード例 #6
0
        public void GetDefaultDocTypesWorks()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();
            IList <DocTypeInfo> defaultDocTypes = client.Settings.GetDefaultDocTypes();

            CollectionAssert.IsNotEmpty(defaultDocTypes);
            Assert.That(defaultDocTypes.Count, Is.EqualTo(5));
            foreach (DocTypeInfo docTypeInfo in defaultDocTypes)
            {
                Assert.IsNotNull(docTypeInfo);
                Assert.That(docTypeInfo.Name, Is.Not.Null);
                Assert.That(docTypeInfo.ShortName, Is.Not.Null);
            }
        }
コード例 #7
0
        public void SaveAppCrashUsingAutonomousApiKeyThrows()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();

            Dictionary <string, object> errorReportInfo = new Dictionary <string, object>
            {
                { "Id", Guid.NewGuid().ToString() },
                { "AppStartTime", DateTime.Now.AddMinutes(-30) },
                { "AppErrorTime", DateTime.Now }
            };

            string         errorReport      = JsonConvert.SerializeObject(errorReportInfo, Formatting.None);
            string         autonomousApiKey = AutonomousAppIdentity.Master.ApiKey;
            AspenException exception        = Assert.Throws <AspenException>(() => client.Utils.SaveAppCrash(autonomousApiKey, Environment.UserName, errorReport));

            Assert.That(exception.EventId, Is.EqualTo("20011"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
            StringAssert.IsMatch("Solicitud no autorizada", exception.Message);
        }
コード例 #8
0
        public void SaveAppCrashWorks()
        {
            IAnonymous client = this.GetAnonymousClient()
                                .RoutingTo(TestingEndpointProvider.Default)
                                .GetClient();

            string recognizedApiKey = DelegatedAppIdentity.Master.ApiKey;
            Dictionary <string, object> errorReportInfo = new Dictionary <string, object>
            {
                { "Id", Guid.NewGuid().ToString() },
                { "AppStartTime", DateTime.Now.AddMinutes(-30) },
                { "AppErrorTime", DateTime.Now }
            };

            // Funciona cuando el objeto json está indentado.
            string errorReport = JsonConvert.SerializeObject(errorReportInfo, Formatting.Indented);

            Assert.DoesNotThrow(() => client.Utils.SaveAppCrash(recognizedApiKey, Environment.UserName, errorReport));

            // Funciona también cuando el objeto json no está indentado.
            errorReport = JsonConvert.SerializeObject(errorReportInfo, Formatting.None);
            Assert.DoesNotThrow(() => client.Utils.SaveAppCrash(recognizedApiKey, Environment.UserName, errorReport));
        }