public void AgencyPasswordPolicy_ValidatePasswordForInvalidReuseCount() { DeveloperIdentity.GetDeveloperIdentity(); const string password = "******"; Guid userId = Utils.CreateUser(password); UserNew userdetails = new UserNew() { PasswordHistory = new Collection <PasswordHistory>() { new PasswordHistory(new Password(new Guid(), userId, "abc")), new PasswordHistory(new Password(new Guid(), userId, "xyz")) } }; passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.PasswordReuse = 5; passwordConfiguration.MaximumLength = 15; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePasswordChange(userdetails, password); Assert.IsFalse(passwordViolations.Count > 0); }
public static IDeveloperIdentity GetDeveloperIdentity() { try { var headers = HttpContext.Current.Request.Headers; var devId = headers["X-Developer-Id"]; var guid = Guid.ParseExact(devId, "N"); var hash = headers["X-Api-Key"]; var identity = new DeveloperIdentity {DeveloperId = guid}; if (!identity.IsValid(hash)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } return identity; } catch (Exception ex) { SnapMDLogger.LogException(ex, "Error parsing developer ID, throwing 401"); throw new HttpResponseException(HttpStatusCode.Unauthorized); } }
public void InitializeTest() { DeveloperIdentity.GetDeveloperIdentity(); }