Skip to content

Commit

Permalink
chore: More store tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed May 2, 2024
1 parent c47e363 commit 89aa7b6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/WingetIntune/Internal/MsStore/store-requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ Content-Type: application/json

###

GET https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=9NZVDKPMR9RD&market=US&languages=en-us
GET https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=9NZVDKPMR9RD&market=US&languages=en-us


###

GET https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/9NZVDKPMR9RD
Accept: application/json
30 changes: 30 additions & 0 deletions tests/WingetIntune.Tests/MsStore/MicrosoftStoreClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@ public async Task GetDisplayCatalogAsync_ReturnsExpectedResult()
Assert.NotNull(image);
}

[Fact]
public async Task GetManifestAsync_ReturnsExpectedResult()
{
const string packageId = "9NZVDKPMR9RD";
const string responseData = @"{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.PackageManifestResponse, StoreEdgeFD"",""Data"":{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.PackageManifestData, StoreEdgeFD"",""PackageIdentifier"":""9NZVDKPMR9RD"",""Versions"":[{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.PackageManifestVersion, StoreEdgeFD"",""PackageVersion"":""Unknown"",""DefaultLocale"":{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.DefaultLocale, StoreEdgeFD"",""PackageLocale"":""en-us"",""Publisher"":""Mozilla"",""PublisherUrl"":""https://www.mozilla.org/firefox/"",""PrivacyUrl"":""https://www.mozilla.org/privacy/firefox/"",""PublisherSupportUrl"":""https://support.mozilla.org/products/firefox"",""PackageName"":""Mozilla Firefox"",""License"":""ms-windows-store://pdp/?ProductId=9NZVDKPMR9RD"",""Copyright"":"""",""ShortDescription"":""Firefox Browser: fast, private & safe web browser\r\n\r\nWhen it comes to your life online, you have a choice: accept the factory settings or put your privacy first. When you choose Firefox for Windows as your default browser, you’re choosing to protect your d..."",""Description"":""Firefox Browser: fast, private & safe web browser\r\n\r\nWhen it comes to your life online, you have a choice: accept the factory settings or put your privacy first. When you choose Firefox for Windows as your default browser, you’re choosing to protect your data while supporting an independent tech company. Firefox is also the only major browser backed by a non-profit fighting to give you more openness, transparency and control of your life online. Join hundreds of millions of people who choose to protect what's important by choosing Firefox - a web browser designed to be fast, easy to use, customizable and private.\r\n\r\nA BROWSER THAT REFLECTS WHO YOU ARE \r\n- You can choose whatever default browser you want. Maybe think about using the only super-fast, ultra-private browser that’s backed by a non-profit? No pressure though.\r\n- Our secret sauce: Firefox Add-ons. They’re like these magical power-ups you can add to your Firefox browser to make it even better.\r\n- From watching a web tutorial to keeping an eye on your favorite team, your video follows you while you multitask with Picture-in-Picture.\r\n\r\nFAST. PRIVATE. SAFE.\r\nFirefox browser gives you effortless privacy protection with lightning-fast page loads. Enhanced Tracking Protection automatically blocks over 2,000 known online trackers from invading your privacy and slowing down your webpages. Firefox browser also introduces a clean new design that makes it easier to get more things done, more quickly. Plus, with smart browsing features built in, Firefox lets you take your privacy, passwords, and bookmarks with you safely wherever you go.\r\n\r\nYOU COME FIRST\r\nAs the internet grows and changes, Firefox continues to focus on your right to privacy — we call it the Personal Data Promise: Take less. Keep it safe. No secrets. Your data, your web activity, your life online is protected with Firefox.\r\n\r\nHOW FIREFOX COMPARES TO OTHER BROWSERS\r\nWhen it comes to all-around performance — speed, design, utility, ease of use, and a steadfast commitment to your privacy — no browser beats Firefox. And being backed by a non-profit means that unlike other browsers, we have no financial stake in following you around the web.\r\n\r\nPICK UP RIGHT WHERE YOU LEFT OFF\r\nStart using Firefox on your phone then switch to the Firefox browser on your computer. With Firefox across your devices you can take your bookmarks, saved logins and browsing history wherever you go. Firefox browser also takes the guesswork out of passwords by remembering your passwords across devices.\r\n\r\nKEEP FACEBOOK OFF YOUR BACK\r\nBuilt for Firefox, the Facebook Container extension helps to stop Facebook from collecting your personal data and web activity when you’re outside of Facebook — yes, they’re actually doing this.\r\n\r\nYOUR SAVE BUTTON FOR THE INTERNET\r\nHit the Pocket button when you come across an interesting article, video, recipe — you know, the good stuff on the internet — but just don’t have the time. Pocket stashes it in your own private, distraction-free space to dive into later.\r\n\r\nMULTITASKING MADE EASY\r\nPlay a video in a separate, scalable window that pins to the front of your desktop with the Picture-in-Picture feature. It stays and plays while you go about your other business on other tabs or do things outside of Firefox. \r\n\r\nEXTENSIONS FOR EVERY INTEREST\r\nFrom security to news to gaming, there’s an extension for everyone. Add as many as you want until your browser is just right.\r\n\r\nCHALLENGING THE STATUS QUO SINCE 1998\r\nFirefox was created by Mozilla as a faster, more private alternative to browsers like Microsoft Edge and Google Chrome. Our mission-driven company and volunteer community continue to put your privacy above all else."",""Tags"":[],""Agreements"":[{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Category"",""Agreement"":""Productivity""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Pricing"",""Agreement"":""Free""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Free Trial"",""Agreement"":""No""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Terms of Transaction"",""AgreementUrl"":""https://aka.ms/microsoft-store-terms-of-transaction""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Seizure Warning"",""AgreementUrl"":""https://aka.ms/microsoft-store-seizure-warning""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.AgreementDetail, StoreEdgeFD"",""AgreementLabel"":""Store License Terms"",""AgreementUrl"":""https://aka.ms/microsoft-store-license""}]},""Installers"":[{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.BigCatInstaller, StoreEdgeFD"",""MSStoreProductIdentifier"":""9NZVDKPMR9RD"",""Architecture"":""x86"",""InstallerType"":""msstore"",""Markets"":{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.Markets, StoreEdgeFD"",""AllowedMarkets"":[""US""]},""PackageFamilyName"":""Mozilla.Firefox_n80bbvh6b1yt2"",""Scope"":""user""},{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.BigCatInstaller, StoreEdgeFD"",""MSStoreProductIdentifier"":""9NZVDKPMR9RD"",""Architecture"":""x64"",""InstallerType"":""msstore"",""Markets"":{""$type"":""Microsoft.Marketplace.Storefront.StoreEdgeFD.BusinessLogic.Response.PackageManifest.Markets, StoreEdgeFD"",""AllowedMarkets"":[""US""]},""PackageFamilyName"":""Mozilla.Firefox_n80bbvh6b1yt2"",""Scope"":""user""}]}]}}";

var httpClient = Substitute.For<HttpClient>();
var logger = Substitute.For<ILogger<MicrosoftStoreClient>>();
var client = new MicrosoftStoreClient(httpClient, logger);
var cancellationToken = new CancellationToken();

var fakeResponse = new HttpResponseMessage
{
Content = new StringContent(responseData, Encoding.UTF8, "application/json")
};

httpClient.SendAsync(Arg.Is<HttpRequestMessage>(req =>
req.Method == HttpMethod.Get
&& req.RequestUri == new Uri($"https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/{packageId}")), cancellationToken)
.Returns(fakeResponse);

// Act
var result = await client.GetManifestAsync(packageId, cancellationToken);

// Assert
Assert.NotNull(result);
Assert.Equal(packageId, result.Data.PackageIdentifier);
Assert.Equal("Mozilla Firefox", result.Data.Versions[0].DefaultLocale.PackageName);
}

[Fact]
public async Task GetPackageIdForFirstMatchAsync_ReturnsExpectedResult()
{
Expand Down

0 comments on commit 89aa7b6

Please sign in to comment.