Skip to content

Commit 7b485f7

Browse files
author
Scott Bommarito
authored
Move NuGet.Services.Entities back into NuGetGallery solution (#6811)
1 parent 06e5747 commit 7b485f7

56 files changed

Lines changed: 3441 additions & 29 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NuGetGallery.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Tools", "4. Tools", "{22
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GalleryTools", "src\GalleryTools\GalleryTools.csproj", "{C5849063-8CDC-4561-BA5C-7D97BD905DC3}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.Entities", "src\NuGet.Services.Entities\NuGet.Services.Entities.csproj", "{6262F4FC-29BE-4226-B676-DB391C89D396}"
32+
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.Entities.Tests", "tests\NuGet.Services.Entities.Tests\NuGet.Services.Entities.Tests.csproj", "{79C831E9-7C88-4B98-B084-4DE940C73FC7}"
34+
EndProject
3135
Global
3236
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3337
Debug|Any CPU = Debug|Any CPU
@@ -58,6 +62,14 @@ Global
5862
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
5963
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
6064
{C5849063-8CDC-4561-BA5C-7D97BD905DC3}.Release|Any CPU.Build.0 = Release|Any CPU
65+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Release|Any CPU.ActiveCfg = Release|Any CPU
68+
{6262F4FC-29BE-4226-B676-DB391C89D396}.Release|Any CPU.Build.0 = Release|Any CPU
69+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
70+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
71+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
72+
{79C831E9-7C88-4B98-B084-4DE940C73FC7}.Release|Any CPU.Build.0 = Release|Any CPU
6173
EndGlobalSection
6274
GlobalSection(SolutionProperties) = preSolution
6375
HideSolutionNode = FALSE
@@ -69,6 +81,8 @@ Global
6981
{8AC9E39E-366C-47E5-80AE-38E71CD31386} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
7082
{6931C2EE-E081-4518-9798-D34D83B35BF6} = {05998089-58F5-4A84-8C11-C5C6244A6F89}
7183
{C5849063-8CDC-4561-BA5C-7D97BD905DC3} = {2204C510-A559-4ED7-9590-FDC09093575B}
84+
{6262F4FC-29BE-4226-B676-DB391C89D396} = {155100FF-524B-4CAF-93C6-A57478B3DBAD}
85+
{79C831E9-7C88-4B98-B084-4DE940C73FC7} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
7286
EndGlobalSection
7387
GlobalSection(ExtensibilityGlobals) = postSolution
7488
SolutionGuid = {064A3BDE-5203-4AD6-A6C9-5CF08301EC8F}

build.ps1

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,28 @@ Invoke-BuildStep 'Restoring solution packages' { `
7676
-ev +BuildErrors
7777

7878
Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
79-
$Paths = `
80-
(Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.g.cs"), `
81-
(Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs")
82-
83-
Foreach ($Path in $Paths) {
84-
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
85-
}
86-
} `
87-
-ev +BuildErrors
79+
$Paths = `
80+
(Join-Path $PSScriptRoot "src\NuGetGallery\Properties\AssemblyInfo.g.cs"), `
81+
(Join-Path $PSScriptRoot "src\NuGetGallery.Core\Properties\AssemblyInfo.g.cs"), `
82+
(Join-Path $PSScriptRoot "src\NuGet.Services.Entities\Properties\AssemblyInfo.g.cs")
8883

89-
Invoke-BuildStep 'Building solution' {
90-
$SolutionPath = Join-Path $PSScriptRoot "NuGetGallery.sln"
91-
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
92-
} `
93-
-ev +BuildErrors
84+
Foreach ($Path in $Paths) {
85+
Set-VersionInfo -Path $Path -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
86+
}
87+
} `
88+
-ev +BuildErrors
9489

95-
Invoke-BuildStep 'Creating artifacts' {
96-
$packageId = 'NuGetGallery.Core'+$PackageSuffix
97-
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId $packageId `
98-
-ev +BuildErrors
99-
}
90+
Invoke-BuildStep 'Building solution' {
91+
$SolutionPath = Join-Path $PSScriptRoot "NuGetGallery.sln"
92+
Build-Solution $Configuration $BuildNumber -MSBuildVersion "15" $SolutionPath -SkipRestore:$SkipRestore -MSBuildProperties "/p:MvcBuildViews=true" `
93+
} `
94+
-ev +BuildErrors
95+
96+
Invoke-BuildStep 'Creating artifacts' { `
97+
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGetGallery.Core\NuGetGallery.Core.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId "NuGetGallery.Core$PackageSuffix"
98+
New-ProjectPackage (Join-Path $PSScriptRoot "src\NuGet.Services.Entities\NuGet.Services.Entities.csproj") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion
99+
} `
100+
-ev +BuildErrors
100101

101102
Trace-Log ('-' * 60)
102103

src/GalleryTools/GalleryTools.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
<Reference Include="System.Data.DataSetExtensions" />
4141
<Reference Include="Microsoft.CSharp" />
4242
<Reference Include="System.Data" />
43-
<Reference Include="System.Net.Http" />
4443
<Reference Include="System.Xml" />
4544
</ItemGroup>
4645
<ItemGroup>
@@ -60,6 +59,10 @@
6059
<Project>{6931C2EE-E081-4518-9798-D34D83B35BF6}</Project>
6160
<Name>NuGet.Services.Search.Client</Name>
6261
</ProjectReference>
62+
<ProjectReference Include="..\NuGet.Services.Entities\NuGet.Services.Entities.csproj">
63+
<Project>{6262f4fc-29be-4226-b676-db391c89d396}</Project>
64+
<Name>NuGet.Services.Entities</Name>
65+
</ProjectReference>
6366
<ProjectReference Include="..\NuGetGallery.Core\NuGetGallery.Core.csproj">
6467
<Project>{097b2cdd-9623-4c34-93c2-d373d51f5b4e}</Project>
6568
<Name>NuGetGallery.Core</Name>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.ComponentModel.DataAnnotations;
6+
7+
namespace NuGet.Services.Entities
8+
{
9+
public class AccountDelete
10+
: IEntity
11+
{
12+
public int Key { get; set; }
13+
14+
/// <summary>
15+
/// The date when the account was deleted.
16+
/// </summary>
17+
[Required]
18+
public DateTime DeletedOn { get; set; }
19+
20+
/// <summary>
21+
/// The deleted account key.
22+
/// </summary>
23+
public int DeletedAccountKey { get; set; }
24+
25+
/// <summary>
26+
/// The deleted account.
27+
/// </summary>
28+
public User DeletedAccount { get; set; }
29+
30+
/// <summary>
31+
/// The User(admin) key that executed the delete action.
32+
/// </summary>
33+
public int DeletedByKey { get; set; }
34+
35+
/// <summary>
36+
/// The User(admin) that executed the delete action.
37+
/// </summary>
38+
public User DeletedBy { get; set; }
39+
40+
/// <summary>
41+
/// The signature of the admin.
42+
/// </summary>
43+
public string Signature { get; set; }
44+
}
45+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.ComponentModel.DataAnnotations;
7+
8+
namespace NuGet.Services.Entities
9+
{
10+
[DisplayColumn(nameof(Thumbprint))]
11+
public class Certificate : IEntity
12+
{
13+
/// <summary>
14+
/// The database-mastered identifier for this certificate.
15+
/// </summary>
16+
public int Key { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets the SHA-1 thumbprint of the certificate.
20+
/// </summary>
21+
public string Sha1Thumbprint { get; set; }
22+
23+
/// <summary>
24+
/// The SHA-256 thumbprint (fingerprint) that uniquely identifies this certificate. This is a string with
25+
/// exactly 64 characters and is the hexadecimal encoding of the hash digest. Note that the SQL column that
26+
/// stores this property allows longer string values to facilitate future hash algorithm changes.
27+
/// </summary>
28+
public string Thumbprint { get; set; }
29+
30+
/// <summary>
31+
/// The subject distinguished name of the certificate.
32+
/// </summary>
33+
public string Subject { get; set; }
34+
35+
/// <summary>
36+
/// The short subject of the certificate. In most cases, this is the CN attribute.
37+
/// </summary>
38+
public string ShortSubject { get; set; }
39+
40+
/// <summary>
41+
/// The issuer distinguished name of the certificate.
42+
/// </summary>
43+
public string Issuer { get; set; }
44+
45+
/// <summary>
46+
/// The short issuer of the certificate. In most cases, this is the CN attribute.
47+
/// </summary>
48+
public string ShortIssuer { get; set; }
49+
50+
/// <summary>
51+
/// The expiration date and time of the certificate.
52+
/// </summary>
53+
public DateTime? Expiration { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the collection of user certificates.
57+
/// </summary>
58+
public ICollection<UserCertificate> UserCertificates { get; set; }
59+
60+
public Certificate()
61+
{
62+
UserCertificates = new List<UserCertificate>();
63+
}
64+
}
65+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace NuGet.Services.Entities
5+
{
6+
public static class Constants
7+
{
8+
public const string AdminRoleName = "Admins";
9+
public const int MaxPackageIdLength = 128;
10+
}
11+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.ComponentModel.DataAnnotations;
7+
using System.ComponentModel.DataAnnotations.Schema;
8+
using System.Linq;
9+
10+
namespace NuGet.Services.Entities
11+
{
12+
public class Credential
13+
: IEntity
14+
{
15+
/// <summary>
16+
/// Represents a credential used by NuGet Gallery. Can be an API key credential,
17+
/// username/password or external credential like Microsoft Account or Azure Active Directory.
18+
/// </summary>
19+
public Credential()
20+
{
21+
Scopes = new List<Scope>();
22+
}
23+
24+
25+
/// <summary>
26+
/// Represents a credential used by NuGet Gallery. Can be an API key credential,
27+
/// username/password or external credential like Microsoft Account or Azure Active Directory.
28+
/// </summary>
29+
/// <param name="type">Credential type. See <see cref="CredentialTypes"/></param>
30+
/// <param name="value">Credential value</param>
31+
public Credential(string type, string value)
32+
: this()
33+
{
34+
Type = type;
35+
Value = value;
36+
}
37+
38+
/// <summary>
39+
/// Represents a credential used by NuGet Gallery. Can be an API key credential,
40+
/// username/password or external credential like Microsoft Account or Azure Active Directory.
41+
/// </summary>
42+
/// <param name="type">Credential type. See <see cref="CredentialTypes"/></param>
43+
/// <param name="value">Credential value</param>
44+
/// <param name="expiration">Optional expiration timespan for the credential.</param>
45+
public Credential(string type, string value, TimeSpan? expiration)
46+
: this(type, value)
47+
{
48+
if (expiration.HasValue && expiration.Value > TimeSpan.Zero)
49+
{
50+
Expires = DateTime.UtcNow.Add(expiration.Value);
51+
ExpirationTicks = expiration.Value.Ticks;
52+
}
53+
}
54+
55+
public int Key { get; set; }
56+
57+
[Required]
58+
public int UserKey { get; set; }
59+
60+
[Required]
61+
[StringLength(maximumLength: 64)]
62+
public string Type { get; set; }
63+
64+
[Required]
65+
[StringLength(maximumLength: 256)]
66+
public string Value { get; set; }
67+
68+
[StringLength(maximumLength: 256)]
69+
public string TenantId { get; set; }
70+
71+
[StringLength(maximumLength: 256)]
72+
public string Description { get; set; }
73+
74+
[StringLength(maximumLength: 256)]
75+
public string Identity { get; set; }
76+
77+
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
78+
public DateTime Created { get; set; }
79+
80+
public DateTime? Expires { get; set; }
81+
82+
public long? ExpirationTicks { get; set; }
83+
84+
public DateTime? LastUsed { get; set; }
85+
86+
public virtual User User { get; set; }
87+
88+
public virtual ICollection<Scope> Scopes { get; set; }
89+
90+
[NotMapped]
91+
public bool HasExpired
92+
{
93+
get
94+
{
95+
if (Expires.HasValue)
96+
{
97+
return DateTime.UtcNow >= Expires.Value;
98+
}
99+
100+
return false;
101+
}
102+
}
103+
104+
public bool HasBeenUsedInLastDays(int numberOfDays)
105+
{
106+
if (numberOfDays > 0 && LastUsed.HasValue)
107+
{
108+
return LastUsed.Value.AddDays(numberOfDays) > DateTime.UtcNow;
109+
}
110+
111+
return true;
112+
}
113+
}
114+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Collections.Generic;
5+
6+
namespace NuGet.Services.Entities
7+
{
8+
public class CuratedFeed
9+
: IEntity
10+
{
11+
public CuratedFeed()
12+
{
13+
Managers = new HashSet<User>();
14+
Packages = new HashSet<CuratedPackage>();
15+
}
16+
17+
public string Name { get; set; }
18+
public virtual ICollection<User> Managers { get; set; }
19+
public virtual ICollection<CuratedPackage> Packages { get; set; }
20+
public int Key { get; set; }
21+
}
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace NuGet.Services.Entities
5+
{
6+
public class CuratedPackage
7+
: IEntity
8+
{
9+
public CuratedFeed CuratedFeed { get; set; }
10+
public int CuratedFeedKey { get; set; }
11+
public PackageRegistration PackageRegistration { get; set; }
12+
public int PackageRegistrationKey { get; set; }
13+
public bool AutomaticallyCurated { get; set; }
14+
public bool Included { get; set; }
15+
public string Notes { get; set; }
16+
public int Key { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)