public void Constructor_NonRemovalOfPasswordDoesNotSetValue() { var credential = new Credential(type: CredentialTypes.Password.V3, value: "a"); var record = new CredentialAuditRecord(credential, removed: false); Assert.Null(record.Value); }
public void Constructor_ExternalCredentialSetsValue(string externalType) { var credential = new Credential(type: externalType, value: "b"); var record = new CredentialAuditRecord(credential, removed: false); Assert.Equal("b", record.Value); }
public void Constructor_RemovalOfNonPasswordSetsValue() { var credential = new Credential(type: "a", value: "b"); var record = new CredentialAuditRecord(credential, removed: true); Assert.Equal("b", record.Value); }
public void Constructor_NonRemovalOfNonPasswordDoesNotSetsValue() { var credential = new Credential(type: "a", value: "b"); var record = new CredentialAuditRecord(credential, removedOrRevoked: false); Assert.Null(record.Value); }
public void Constructor_WithRevocationSource_Properties() { var testRevocationSource = "TestRevocationSource"; var credential = new Credential(type: "a", value: "b"); var record = new CredentialAuditRecord(credential, removedOrRevoked: true, revocationSource: testRevocationSource); Assert.Equal(testRevocationSource, record.RevocationSource); Assert.Equal("a", record.Type); Assert.Equal("b", record.Value); }
public UserAuditRecord(User user, AuditedUserAction action) : base(action) { if (user == null) { throw new ArgumentNullException(nameof(user)); } Username = user.Username; EmailAddress = user.EmailAddress; UnconfirmedEmailAddress = user.UnconfirmedEmailAddress; Roles = user.Roles.Select(r => r.Name).ToArray(); Credentials = user.Credentials.Where(CredentialTypes.IsSupportedCredential) .Select(c => new CredentialAuditRecord(c, removed: false)).ToArray(); AffectedCredential = new CredentialAuditRecord[0]; AffectedPolicies = new AuditedUserSecurityPolicy[0]; }
public FailedAuthenticatedOperationAuditRecord( string usernameOrEmail, AuditedAuthenticatedOperationAction action, AuditedPackageIdentifier attemptedPackage = null, Credential attemptedCredential = null) : base(action) { UsernameOrEmail = usernameOrEmail; if (attemptedPackage != null) { AttemptedPackage = attemptedPackage; } if (attemptedCredential != null) { AttemptedCredential = new CredentialAuditRecord(attemptedCredential, removed: false); } }
public void Constructor_SetsProperties() { var created = DateTime.MinValue; var expires = DateTime.MinValue.AddDays(1); var lastUsed = DateTime.MinValue.AddDays(2); var credential = new Credential() { Created = created, Description = "a", Expires = expires, Identity = "b", TenantId = "c", Key = 1, LastUsed = lastUsed, Scopes = new List <Scope>() { new Scope(subject: "c", allowedAction: "d") }, Type = "e", Value = "f" }; var record = new CredentialAuditRecord(credential, removed: true); Assert.Equal(created, record.Created); Assert.Equal("a", record.Description); Assert.Equal(expires, record.Expires); Assert.Equal("b", record.Identity); Assert.Equal("c", record.TenantId); Assert.Equal(1, record.Key); Assert.Equal(lastUsed, record.LastUsed); Assert.Single(record.Scopes); var scope = record.Scopes[0]; Assert.Equal("c", scope.Subject); Assert.Equal("d", scope.AllowedAction); Assert.Equal("e", record.Type); Assert.Equal("f", record.Value); }