storemockserver

package
v0.0.0-...-155e9e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package storemockserver implements a mocked version of the Windows Runtime components involved in the MS Store API that talks via REST. DO NOT USE IN PRODUCTION

Index

Constants

View Source
const (

	//AllAuthenticatedUsersPath is the path to GET the list of anonymous user ID's locally authenticated.
	AllAuthenticatedUsersPath = "/allauthenticatedusers"

	// GenerateUserJWTPath is the path to GET the user's store ID key (a.k.a. JWT).
	GenerateUserJWTPath = "/generateuserjwt"

	// ProductPath is the path to GET a collection of products related to the current application.
	ProductPath = "/products"

	// PurchasePath is the path to GET to purchase a subscription.
	PurchasePath = "/purchase"

	// ProductIDParam is the URL encoded key parameter to the product ID.
	ProductIDParam = "id"

	// ProductIDsParam is the plural version of the above for retrieving a collection of products associated with the current application.
	ProductIDsParam = "ids"

	// ProductKindsParam is the URL encoded key parameter to filter the collection of products associated with the current application.
	ProductKindsParam = "kinds"

	// ServiceTicketParam is the URL encoded key parameter to the service ticket input to generate the user JWT (a.k.a. the Azure AD token).
	ServiceTicketParam = "serviceticket"

	// PublisherUserIDParam is the URL encoded key parameter to the anonymous user ID to be encoded in the JWT (a.k.a. the user ID).
	PublisherUserIDParam = "publisheruserid"

	// CannotPurchaseValue is the product ID that triggers a product purchase error.
	CannotPurchaseValue = "cannotpurchase"

	// ExpiredTokenValue is a token input that triggers the expired AAD token error.
	ExpiredTokenValue = "expiredtoken"

	// NonExistentValue is the product ID that triggers a product not found error.
	NonExistentValue = "nonexistent"

	// ServerErrorValue is the product ID and service ticket inputs that triggers an internal server error.
	ServerErrorValue = "servererror"

	// AlreadyPurchasedResult is the response value from the purchase endpoint when the user has previously purchased the supplied product ID.
	AlreadyPurchasedResult = "AlreadyPurchased"

	// NotPurchasedResult is the response value from the purchase endpoint when not even the store known why it failed :) .
	NotPurchasedResult = "NotPurchased"

	// ServerErrorResult is the response value from the purchase endpoint when an internal server error happens.
	ServerErrorResult = "ServerError"

	// SucceededResult is the response value of a succesfull purchase.
	SucceededResult = "Succeeded"

	// UsersResponseKey is the JSON key of the response containing the list of locally authenticated users.
	UsersResponseKey = "users"

	// JWTResponseKey is the JSON key of the user JWT response.
	JWTResponseKey = "jwt"

	// PurchaseStatusKey is the JSON key of the purchase status response.
	PurchaseStatusKey = "status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Product

type Product struct {
	StoreID            string
	Title              string
	Description        string
	IsInUserCollection bool
	ProductKind        string
	ExpirationDate     time.Time
}

Product models the interesting properties from the MS StoreProduct type.

type Server

type Server struct {
	restserver.ServerBase
	// contains filtered or unexported fields
}

Server is a configurable mock of the MS Store runtime component that talks REST.

func NewServer

func NewServer(s Settings) *Server

NewServer creates a new store mock server with the provided Settings.

type Settings

type Settings struct {
	AllAuthenticatedUsers restserver.Endpoint
	GenerateUserJWT       restserver.Endpoint
	GetProducts           restserver.Endpoint
	Purchase              restserver.Endpoint

	AllProducts []Product
}

Settings contains the parameters for the Server.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the default set of Settings for the server.

func (Settings) Unmarshal

func (s Settings) Unmarshal(in []byte, unmarshaller func(in []byte, out interface{}) (err error)) (restserver.Settings, error)

Unmarshal tricks the type system so marshalling YAML will just work when called from the restserver.Settings interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL