public void UsingRandomDeviceIdWhenUserSigninRequestWorks() { IPayloadClaimsManager randomDeviceIdClaimBehavior = InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"MyRandomDevice-{new Random().Next(999999, 9999999)}"); ServiceLocator.Instance.RegisterPayloadClaimsManager(randomDeviceIdClaimBehavior); IDelegatedApp client = this.GetDelegatedClient(); Assert.That(client, Is.Not.Null); Assert.That(client.AuthToken, Is.Not.Null); Assert.That(client.AuthToken.Token, Is.Not.Null); }
public void MismatchDeviceIdWhenUserSignedRequestThrows() { IDelegatedApp client = this.GetDelegatedClient(); IPayloadClaimsManager randomDeviceIdClaimBehavior = InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"MyRandomDevice-{new Random().Next(999999, 9999999)}"); ServiceLocator.Instance.RegisterPayloadClaimsManager(randomDeviceIdClaimBehavior); AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes()); Assert.That(exception.EventId, Is.EqualTo("15847")); Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); StringAssert.IsMatch("No hay un token de autenticación vigente.", exception.Message); }
public void InvalidFormatDeviceIdWhenUserSigninRequestThrows() { IList <IPayloadClaimsManager> deviceIdClaimBehaviors = new List <IPayloadClaimsManager> { InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => "gXjyhrYqannHUA$LLV&7guTHmF&1X5JB$Uobx3@!rPn9&x4BzE"), InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"{Guid.NewGuid()}-{Guid.NewGuid()}-{Guid.NewGuid()}") }; foreach (IPayloadClaimsManager behavior in deviceIdClaimBehaviors) { ServiceLocator.Instance.RegisterPayloadClaimsManager(behavior); AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient()); Assert.That(exception.EventId, Is.EqualTo("15852")); Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); StringAssert.IsMatch("'DeviceId' debe coincidir con el patrón", exception.Message); } }
public void NullOrEmptyDeviceIdWhenUserSigninRequestThrows() { IList <IPayloadClaimsManager> deviceIdClaimBehaviors = new List <IPayloadClaimsManager>() { InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => null), InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => string.Empty), InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => " ") }; foreach (IPayloadClaimsManager behavior in deviceIdClaimBehaviors) { ServiceLocator.Instance.RegisterPayloadClaimsManager(behavior); AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient()); Assert.That(exception.EventId, Is.EqualTo("15852")); Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); StringAssert.IsMatch("'DeviceId' no puede ser nulo ni vacío", exception.Message); } }