public HomeController(ISessionStateAccess sessionState, IAppSettingsAccess appSettings,
     IOAuth2ServerAccess oauth2Server, IWebApiAccess webApi, IResourcesAccess resources, ILogging logging,
     IGlobalStateAccess globalState)
     : base(sessionState, appSettings, oauth2Server, webApi, resources, logging, globalState)
 {
 }
 public void TearDown()
 {
     _substituteAppSettings = null;
 }
        // Returns a tuple whose first item contains the URI to redirect to, in order to request an authorization
        // code from the StatPro Revolution OAuth2 Server.  The second item contains the 'state' value that's
        // included in the URI.  'appSettings' give access to application settings, and must be non-null.
        public static Tuple<String, Int32> GetAuthorizationRequestInfo(IAppSettingsAccess appSettings)
        {
            if (appSettings == null)
                return null;

            // Get the data we need from app settings.
            var authEndpointUri = appSettings.OAuth2ServerAuthorizationEndpointUri;
            var publicId = appSettings.ClientApplicationPublicId;
            var redirectUri = appSettings.ClientApplicationRedirectUri;
            var scopeList = appSettings.RevolutionResourceServers;

            // State = a random, positive integer.
            var state = _random.Next();

            // Form the URI to redirect to.
            var uri = String.Format(CultureInfo.InvariantCulture,
                "{0}?response_type=code&client_id={1}&redirect_uri={2}&scope={3}&state={4}",
                authEndpointUri,
                Uri.EscapeDataString(publicId),
                Uri.EscapeDataString(redirectUri),
                Uri.EscapeDataString(scopeList),
                state);

            // Return the resulting URI + the state value.
            return Tuple.Create<String, Int32>(uri, state);
        }
 public void Setup()
 {
     _substituteAppSettings = Substitute.For<IAppSettingsAccess>();
 }