Beispiel #1
0
            protected override void Arrange()
            {
                _clientAppRepo          = A.Fake <IClientAppRepo>();
                _accessTokenClientRepo  = A.Fake <IAccessTokenClientRepo>();
                _apiClientAuthenticator = A.Fake <IApiClientAuthenticator>();

                _tokenRequest = new TokenRequest
                {
                    Client_id     = ClientId,
                    Client_secret = ClientSecret,
                    Grant_type    = "client_credentials"
                };

                _apiClientAuthenticator = A.Fake <IApiClientAuthenticator>();

                A.CallTo(() => _apiClientAuthenticator.TryAuthenticateAsync(A <string> ._, A <string> ._))
                .Returns(
                    Task.FromResult <ApiClientAuthenticator.AuthenticationResult>(
                        new ApiClientAuthenticator.AuthenticationResult
                {
                    IsAuthenticated   = true,
                    ApiClientIdentity = new ApiClientIdentity
                    {
                        Key = ClientId,
                    }
                }));
            }
Beispiel #2
0
            protected override void Arrange()
            {
                _clientAppRepo = MockRepository.GenerateStub <IClientAppRepo>();

                _tokenRequest = new TokenRequest
                {
                    Client_id = ClientId, Client_secret = ClientSecret
                };

                _apiClientAuthenticator = MockRepository.GenerateStub <IApiClientAuthenticator>();
                ApiClientIdentity apiClientIdentity;

                _apiClientAuthenticator
                .Expect(aca => aca.TryAuthenticate(null, null, out apiClientIdentity))
                .IgnoreArguments()
                .Do(
                    new ApiClientAuthenticatorDelegates.TryAuthenticateDelegate(
                        (string key, string password, out ApiClientIdentity identity) =>
                {
                    identity = null;
                    return(false);
                }));

                _clientCredentialsTokenRequestHandler = new ClientCredentialsTokenRequestHandler(_clientAppRepo, _apiClientAuthenticator);
            }
            protected override void Arrange()
            {
                _configValueProvider = A.Fake <IConfigValueProvider>();
                A.CallTo(() => _configValueProvider.GetValue(A <string> ._)).Returns("5");

                _clientAppRepo = A.Fake <IClientAppRepo>();

                _defaultApplicationCreator = A.Fake <IDefaultApplicationCreator>();

                _sandboxProvisioner = A.Fake <ISandboxProvisioner>();

                _clientCreator = new ClientCreator(_configValueProvider, _clientAppRepo, _defaultApplicationCreator, _sandboxProvisioner);

                _user = A.Fake <User>();

                A.CallTo(() => _user.ApiClients).Returns(
                    new List <ApiClient>
                {
                    A.Fake <ApiClient>(),
                    A.Fake <ApiClient>(),
                    A.Fake <ApiClient>(),
                    A.Fake <ApiClient>(),
                    A.Fake <ApiClient>()
                });
            }
 public SecurityService(IHttpContextAccessor httpContextAccessor
                        , IClientAppRepo clientAppRepo
                        , IIdentityProvider identityProvider)
 {
     _clientAppRepo       = clientAppRepo;
     _identityProvider    = identityProvider;
     _httpContextAccessor = httpContextAccessor;
 }
Beispiel #5
0
 public ClientCredentialsTokenRequestProvider(
     IClientAppRepo clientAppRepo,
     IApiClientAuthenticator apiClientAuthenticator,
     IAccessTokenClientRepo accessTokenClientRepo)
 {
     _clientAppRepo          = clientAppRepo;
     _apiClientAuthenticator = apiClientAuthenticator;
     _accessTokenClientRepo  = accessTokenClientRepo;
 }
 public ClientAppManager(IClientAppRepo repo, IAppConfig appConfig, IAdminLogger logger, ISecureStorage secureStorage,
                         IUserManager userManager, IOrganizationManager orgManager, IDependencyManager depmanager, ISecurity security) : base(logger, appConfig, depmanager, security)
 {
     _repo          = repo ?? throw new ArgumentNullException(nameof(repo));
     _appConfig     = appConfig ?? throw new ArgumentNullException(nameof(appConfig));
     _secureStorage = secureStorage ?? throw new ArgumentNullException(nameof(secureStorage));
     _userManager   = userManager ?? throw new ArgumentNullException(nameof(userManager));
     _orgManager    = orgManager ?? throw new ArgumentNullException(nameof(orgManager));
 }
 public AccountController(
     IUserAccountManager userAccountManager,
     IPasswordService passwordService,
     ISecurityService securityService,
     IClientAppRepo clientAppRepo)
 {
     _userAccountManager = userAccountManager;
     _passwordService    = passwordService;
     _securityService    = securityService;
     _clientAppRepo      = clientAppRepo;
 }
Beispiel #8
0
 public UserAccountManager(
     IClientAppRepo clientAppRepository,
     IEmailService emailService,
     IPasswordService passwordService,
     ISecurityService securityService)
 {
     _clientAppRepository = clientAppRepository;
     _emailService        = emailService;
     _passwordService     = passwordService;
     _securityService     = securityService;
 }
 public ClientController(
     IClientAppRepo repository,
     ISecurityService securityService,
     ISandboxProvisioner sandboxProvisioner,
     IClientCreator clientCreator)
 {
     _repository         = repository;
     _securityService    = securityService;
     _sandboxProvisioner = sandboxProvisioner;
     _clientCreator      = clientCreator;
 }
 public AccountController(
     IUserAccountManager userAccountManager,
     IPasswordService passwordService,
     IClientAppRepo clientAppRepo,
     IHttpContextAccessor httpContextAccessor
     )
 {
     _userAccountManager  = userAccountManager;
     _passwordService     = passwordService;
     _clientAppRepo       = clientAppRepo;
     _httpContextAccessor = httpContextAccessor;
 }
Beispiel #11
0
 public UpdateAdminDatabaseTask(IClientAppRepo clientAppRepo,
                                IDefaultApplicationCreator defaultApplicationCreator,
                                IConfiguration configuration,
                                ApiSettings apiSettings,
                                IConfigurationRoot configurationRoot)
 {
     _clientAppRepo             = clientAppRepo;
     _defaultApplicationCreator = defaultApplicationCreator;
     _configuration             = configuration;
     _apiSettings       = apiSettings;
     _configurationRoot = configurationRoot;
 }
Beispiel #12
0
 public UserAccountManager(
     IClientAppRepo clientAppRepository,
     IEmailService emailService,
     IPasswordService passwordService,
     ISecurityService securityService,
     IIdentityProvider identityProvider)
 {
     _clientAppRepository = clientAppRepository;
     _emailService        = emailService;
     _passwordService     = passwordService;
     _identityProvider    = identityProvider;
 }
Beispiel #13
0
        public ClientCreator(
            IConfigValueProvider configValueProvider,
            IClientAppRepo clientAppRepo,
            IDefaultApplicationCreator defaultApplicationCreator,
            ISandboxProvisioner sandboxProvisioner)
        {
            _sandboxProvisioner      = sandboxProvisioner;
            _configValueProvider     = Preconditions.ThrowIfNull(configValueProvider, nameof(configValueProvider));
            _maximumSandboxesPerUser = GetMaximumSandboxesPerUserOrDefault();

            _clientAppRepo             = Preconditions.ThrowIfNull(clientAppRepo, nameof(clientAppRepo));
            _defaultApplicationCreator = Preconditions.ThrowIfNull(defaultApplicationCreator, nameof(defaultApplicationCreator));
        }
 public ClientCreator(
     IConfiguration configValueProvider,
     IClientAppRepo clientAppRepo,
     IDefaultApplicationCreator defaultApplicationCreator,
     ITemplateDatabaseLeaQuery templateDatabaseLeaQuery,
     ISandboxProvisioner sandboxProvisioner)
 {
     _sandboxProvisioner        = sandboxProvisioner;
     _configuration             = Preconditions.ThrowIfNull(configValueProvider, nameof(configValueProvider));
     _maximumSandboxesPerUser   = GetMaximumSandboxesPerUserOrDefault();
     _templateDatabaseLeaQuery  = Preconditions.ThrowIfNull(templateDatabaseLeaQuery, nameof(templateDatabaseLeaQuery));
     _clientAppRepo             = Preconditions.ThrowIfNull(clientAppRepo, nameof(clientAppRepo));
     _defaultApplicationCreator = Preconditions.ThrowIfNull(defaultApplicationCreator, nameof(defaultApplicationCreator));
 }
 public InitializationEngine(
     InitializationModel initializationModel,
     IClientAppRepo clientAppRepo,
     IClientCreator clientCreator,
     ITemplateDatabaseLeaQuery templateDatabaseLeaQuery,
     IDefaultApplicationCreator applicationCreator
     )
 {
     _settings                 = initializationModel;
     _clientAppRepo            = clientAppRepo;
     _clientCreator            = clientCreator;
     _templateDatabaseLeaQuery = templateDatabaseLeaQuery;
     _applicationCreator       = applicationCreator;
 }
 public InitializationEngine(
     IOptions <Dictionary <string, UserOptions> > users,
     IClientAppRepo clientAppRepo,
     IClientCreator clientCreator,
     ITemplateDatabaseLeaQuery templateDatabaseLeaQuery,
     IDefaultApplicationCreator applicationCreator,
     IIdentityProvider identityProvider
     )
 {
     _users                    = users.Value;
     _clientAppRepo            = clientAppRepo;
     _clientCreator            = clientCreator;
     _templateDatabaseLeaQuery = templateDatabaseLeaQuery;
     _applicationCreator       = applicationCreator;
     _identityProvider         = identityProvider;
 }
            protected override void Arrange()
            {
                var apiClient = new ApiClient {
                    ApiClientId = 0
                };

                _clientAppRepo          = A.Fake <IClientAppRepo>();
                _apiClientAuthenticator = A.Fake <IApiClientAuthenticator>();

                A.CallTo(() => _clientAppRepo.GetClient(A <string> ._)).Returns(apiClient);

                A.CallTo(() => _clientAppRepo.AddClientAccessToken(A <int> ._, A <string> ._))
                .Returns(new ClientAccessToken {
                    ApiClient = new ApiClient()
                });

                _tokenRequest = new TokenRequest
                {
                    Client_id     = ClientId,
                    Client_secret = ClientSecret,
                    Grant_type    = "client_credentials"
                };

                var clientSecret = new ApiClientSecret
                {
                    IsHashed = true,
                    Secret   = ClientSecret
                };

                A.CallTo(() => _apiClientAuthenticator.TryAuthenticateAsync(A <string> ._, A <string> ._))
                .Returns(
                    Task.FromResult <ApiClientAuthenticator.AuthenticationResult>(
                        new ApiClientAuthenticator.AuthenticationResult
                {
                    IsAuthenticated   = true,
                    ApiClientIdentity = new ApiClientIdentity
                    {
                        Key = ClientId,
                    }
                }));
            }
Beispiel #18
0
        public static TokenController CreateTokenController(
            IClientAppRepo clientAppRepo,
            IApiClientAuthenticator apiClientAuthenticator,
            IAccessTokenClientRepo accessTokenClientRepo)
        {
            var tokenRequestProvider = new ClientCredentialsTokenRequestProvider(clientAppRepo, apiClientAuthenticator, accessTokenClientRepo);
            var controller           = new TokenController(tokenRequestProvider);
            var request = A.Fake <HttpRequest>();

            request.Method = "Post";
            request.Scheme = "http";

            A.CallTo(() => request.Host).Returns(new HostString("localhost", 80));

            request.PathBase    = "/";
            request.RouteValues = new RouteValueDictionary {
                { "controller", "authorize" }
            };

            var httpContext = A.Fake <HttpContext>();

            A.CallTo(() => httpContext.Request).Returns(request);

            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };

            var routeData = A.Fake <RouteData>();
            RouteValueDictionary dictionary = new RouteValueDictionary {
                { "controller", "authorize" }
            };

            controllerContext.RouteData  = new RouteData(dictionary);
            controller.ControllerContext = controllerContext;

            return(controller);
        }
Beispiel #19
0
            protected override void Arrange()
            {
                var apiClient = new ApiClient
                {
                    ApiClientId = 0
                };

                _clientAppRepo = mocks.Stub <IClientAppRepo>();

                _clientAppRepo.Expect(c => c.GetClient(Arg <string> .Is.Anything))
                .Return(apiClient);

                _clientAppRepo.Expect(c => c.AddClientAccessToken(0))
                .Return(new ClientAccessToken());

                _tokenRequest = new TokenRequest
                {
                    Client_id = ClientId, Client_secret = ClientSecret
                };

                _apiClientAuthenticator = _apiClientAuthenticatorHelper.Mock(mocks);

                _clientCredentialsTokenRequestHandler = new ClientCredentialsTokenRequestHandler(_clientAppRepo, _apiClientAuthenticator);
            }
Beispiel #20
0
 public ClientCredentialsTokenRequestHandler(IClientAppRepo clientAppRepo, IApiClientAuthenticator apiClientAuthenticator)
 {
     _clientAppRepo          = clientAppRepo;
     _apiClientAuthenticator = apiClientAuthenticator;
 }
Beispiel #21
0
 public SecurityService(IClientAppRepo clientAppRepo)
 {
     _clientAppRepo = clientAppRepo;
 }
 public PasswordService(IClientAppRepo clientAppRepository)
 {
     _clientAppRepository = clientAppRepository;
 }
 public ClientAppManager(IClientAppRepo repo, IAppConfig appConfig, IAdminLogger logger, ISecureStorage secureStorage,
                         IDependencyManager depmanager, ISecurity security) : base(logger, appConfig, depmanager, security)
 {
     _repo          = repo;
     _secureStorage = secureStorage;
 }
Beispiel #24
0
 public EdFiAdminApiClientIdentityProvider(IClientAppRepo clientAppRepo)
 {
     _clientAppRepo = clientAppRepo;
 }
 public UserProfileController(IClientAppRepo clientAppRepo)
 {
     _clientAppRepo = clientAppRepo;
 }
 public SandboxController(ISandboxProvisioner sandboxProvisioner, IClientAppRepo clientAppRepo, IDatabaseNameBuilder databaseNameBuilder)
 {
     _sandboxProvisioner  = sandboxProvisioner;
     _clientAppRepo       = clientAppRepo;
     _databaseNameBuilder = databaseNameBuilder;
 }