public void WithinBeforeRange() { var inspector = new TimestampRangeInspector(new TimeSpan(1, 0, 0), new TimeSpan(0, 0, 0), () => new DateTime(2008, 1, 1, 12, 0, 0)); var context = new OAuthContext { Timestamp = new DateTime(2008, 1, 1, 11, 0, 0).Epoch().ToString() }; inspector.InspectContext(ProviderPhase.GrantRequestToken, context); }
public void OutsideBeforeRange() { var inspector = new TimestampRangeInspector(new TimeSpan(1, 0, 0), new TimeSpan(0, 0, 0), () => new DateTime(2008, 1, 1, 12, 0, 0)); var context = new OAuthContext { Timestamp = new DateTime(2008, 1, 1, 10, 59, 59).Epoch().ToString() }; var ex = Assert.Throws<OAuthException>(() => inspector.InspectContext(ProviderPhase.GrantRequestToken, context)); Assert.Equal("The timestamp is to old, it must be at most 3600 seconds before the servers current date and time", ex.Message); }