Skip to content

Commit

Permalink
Add some commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Eden committed Nov 28, 2016
1 parent 44420e5 commit 20728a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Quondam/IClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

namespace MartinEden.Quondam
{
/// <summary>
/// A clock provides a way of getting the current time. The purpose here is to take the
/// global static DateTime object, and wrap it in an interface that allows us to mock
/// it in the tests. That way, the tests can control timing precisely.
///
/// Note that this in an internal interface, and the PasswordManager constructor that
/// takes a clock is also internal. This is so that this detail is hidden from consumers
/// of the library - they just get the expected behaviour with a real clock. Because the
/// unit tests have access to internal members of this library, they can still make use
/// of this interface and the constructor.
/// </summary>
internal interface IClock
{
DateTime Now { get; }
Expand Down
9 changes: 9 additions & 0 deletions Quondam/IPasswordManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ namespace MartinEden.Quondam
{
public interface IPasswordManager
{
/// <summary>
/// Generate a 16 character password for any given username. This password
/// is guaranteed to be distinct from any other user's password.
/// </summary>
string GenerateOneTimePassword(string username);
/// <summary>
/// Returns true if the provided password was the one generated for the user
/// the last time GenerateOneTimePassword was called for that user. Only
/// returns true if the password was generated within the last 30 seconds.
/// </summary>
bool ValidatePassword(string username, string password);
}
}

0 comments on commit 20728a6

Please sign in to comment.