Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional test for temp keys #3664

Merged
merged 3 commits into from
Mar 16, 2017
Merged

Functional test for temp keys #3664

merged 3 commits into from
Mar 16, 2017

Conversation

chenriksson
Copy link
Member

No description provided.


var json = JObject.Parse(responseText);
var expiration = json.Value<DateTime>("Expires");
Assert.True(DateTime.UtcNow - expiration < TimeSpan.FromMinutes(5));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.True can have a second parameter which is reason. It should be used to express more details about this expression if it fails (the delta perhaps?).


var json = JObject.Parse(responseText);
var expiration = json.Value<DateTime>("Expires");
Assert.True(DateTime.UtcNow - expiration < TimeSpan.FromMinutes(5));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateTime.UtcNow should be about 1 day less than expiration right? The resulting TimeSpan from this subtraction will be close to a negative day. Perhaps we could assert that the delta is something close to 24 hours?

[Category("P1Tests")]
public async Task VerifyPackageKeySupportsFullAndTempApiKeys()
{
var packageId = $"VerifyPackageKeySupportsFullAndTempApiKeys.{DateTime.UtcNow.Ticks}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use DateTimeOffset whenever possible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticks is used by many other test cases, but can switch if you feel strongly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was confusing. I mean DateTimeOffset.Ticks instead of DateTime.Ticks. And DateTimeOffset everywhere else in your new code.

Truth be told you can do most of the same stuff with DateTime and DateTimeOffset, but I think DateTimeOffset should be our default stance since it forces you to think about timezone every time you use it. It may be irrelevant in this case where we just want to make a unique package ID but I think consistency is better so we don't have to think about the quirky differences between the two APIs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very much a style comment vs. a comment on functionality.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries - switched for my test alone, but maybe I'll set a trend here. :-)

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

var verificationKey = await CreateVerificationKey(packageId, packageVersion);

Assert.Equal(HttpStatusCode.OK, await VerifyPackageKey(verificationKey, packageId, packageVersion));
Assert.Equal(HttpStatusCode.Forbidden, await VerifyPackageKey(verificationKey, packageId, packageVersion));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see each scenario as an individual test instead of having one mega test cover all scenarios for VerifyPackageKey(...).

request.Method = "POST";
request.ContentLength = 0;
request.Headers.Add("X-NuGet-ApiKey", EnvironmentSettings.TestAccountApiKey);
request.Headers.Add("X-NuGet-Client-Version", "NuGetGallery.FunctionalTests");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the server side do we treat this value as an opaque string or do we try to parse it as a version? I assume it's the former but just checking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, former

@chenriksson chenriksson merged commit 5e9b0ed into dev Mar 16, 2017
@chenriksson chenriksson deleted the chenriks-tempkeys-functest branch March 16, 2017 22:15
jozefizso added a commit to goit/NuGetGallery that referenced this pull request Apr 20, 2017
…7.03.27

* tag 'v2017.03.27': (205 commits)
  Revert UpdateIsLatest optimistic concurrency changes (NuGet#3707)
  UpdateIsLatest concurrent unlist fix (NuGet#3695)
  Change telemetry time to use correct format (NuGet#3690)
  Fix typo of "publically" (NuGet#3636)
  Fix regression (NuGet#3667)
  Add credential to Register and RequestPasswordReset audits (NuGet#3666)
  Functional test for temp keys (NuGet#3664)
  Telemetry for temp keys (NuGet#3662)
  Temp keys implementation (NuGet#3563) (NuGet#3646)
  Extracting code: single type per file (NuGet#3644)
  Telemetry for package push (NuGet#3649)
  Upgrade to NuGet.* v4.0.0 dependencies (NuGet#3643)
  Fix concurrent push test by disabling search hijacking on feed (NuGet#3641)
  Fixing Package Description truncation (NuGet#3638)
  Fix Microsoft Account removal (NuGet#3639)
  Send e-mail when a new API key is created (NuGet#3634)
  IsLatest Fix: wrong connection string passed to retry context (NuGet#3632)
  Update WindowsAzure.Storage to 7.0.0 (NuGet#3633)
  Depend on signed version of Elmah (NuGet#3609)
  Move AzureEntityList and TableErrorLog to NuGetGallery.Core (NuGet#3607)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants