11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4+ using System ;
45using System . Threading . Tasks ;
56using System . Web ;
67using Moq ;
78using NuGet . Services . Entities ;
89using NuGet . Services . Messaging . Email ;
910using NuGetGallery . Areas . Admin ;
11+ using NuGetGallery . Configuration ;
1012using NuGetGallery . Framework ;
1113using NuGetGallery . Infrastructure . Mail . Messages ;
1214using NuGetGallery . ViewModels ;
@@ -88,6 +90,41 @@ public async Task HtmlEncodesTheSupportRequest()
8890 It . IsAny < User > ( ) ,
8991 It . IsAny < Package > ( ) ) ) ;
9092 }
93+
94+ [ Fact ]
95+ public async Task WithExternalPrivacyUrlConfigured ( )
96+ {
97+ var externalPrivacyUrl = "https://privacy.microsoft.com" ;
98+ var configuration = GetConfigurationService ( ) ;
99+ var pagesController = GetController < PagesController > ( ) ;
100+
101+ configuration . Current . ExternalPrivacyPolicyUrl = externalPrivacyUrl ;
102+
103+ var result = await pagesController . Privacy ( ) ;
104+
105+ GetMock < IContentService > ( )
106+ . Verify ( m => m . GetContentItemAsync (
107+ It . IsAny < string > ( ) ,
108+ It . IsAny < TimeSpan > ( ) ) , Times . Never ) ;
109+
110+ }
111+
112+ [ Fact ]
113+ public async Task WithoutExternalPrivacyUrlConfigured ( )
114+ {
115+ var externalPrivacyUrl = "" ;
116+ var configuration = GetConfigurationService ( ) ;
117+ var pagesController = GetController < PagesController > ( ) ;
118+
119+ configuration . Current . ExternalPrivacyPolicyUrl = externalPrivacyUrl ;
120+
121+ var result = await pagesController . Privacy ( ) ;
122+
123+ GetMock < IContentService > ( )
124+ . Verify ( m => m . GetContentItemAsync (
125+ It . IsAny < string > ( ) ,
126+ It . IsAny < TimeSpan > ( ) ) , Times . Once ) ;
127+ }
91128 }
92129 }
93130}
0 commit comments