ComponentSpace

Forums



Is it possible to provide own timestamp instead of DateTime.UtcNow?


Is it possible to provide own timestamp instead of DateTime.UtcNow?

Author
Message
mstum-so
mstum-so
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 2, Visits: 13
This is mainly for unit/integration test purposes, but whenever we see an "interesting" SAML Response, we add it to our test suite to make sure we don't regress in supporting it.

However, because things like Conditions.IsWithinTimePeriod refer to DateTime.UtcNow, I'll need to deal with the fact that conditions are no longer valid. Right now, I handle this by passing in a large clockSkew argument.

I do wonder if you could consider an IClock Interface, with a default implementation of IClock.UtcNow => DateTIme.UtcNow but one that I could override with DI?

Our Test Suite can pass in the proper UtcNow that fits the SAML Response under test. There are other cases, e.g., Certificate Expiration, I'm not sure how feasible it is to properly cover those.

ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
Thanks for the suggestion. We'll add this to the backlog for consideration.

How would you know what UTC time to return?

Would this vary depending on when the SAML response was captured?

Regards
ComponentSpace Development
mstum-so
mstum-so
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 2, Visits: 13
ComponentSpace - 2/24/2022
Thanks for the suggestion. We'll add this to the backlog for consideration.

How would you know what UTC time to return?

Would this vary depending on when the SAML response was captured?

Yeah. I basically have different tests for known SAML Responses that we've captured over time, so I know that I need e.g., 2018-05-10 17:24:43 for one and 2019-04-12 14:33:18 for another one. So we'd have an IClock implementation that's tied to a specific unit test and returns the UtcNow value that we need for that one test. (Ideally, I'd love for IClock to be Transient so I can run tests in parallel without messing with a static variable, but we can make a Singleton work as well if needed)

ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
Thanks for the extra feedback.


Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 2 queries. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Select a Forum....












Forums, Documentation & Knowledge Base - ComponentSpace


Search