Exemplo n.º 1
0
        public ApiKeyAuthTests()
        {
            //System.Diagnostics.Debugger.Break();
            appHost = new AppHost()
                      .Init()
                      .Start("http://*:2337/");

            var client   = new JsonServiceClient(ListeningOn);
            var response = client.Post(new Register
            {
                UserName    = Username,
                Password    = Password,
                Email       = "as@if{0}.com",
                DisplayName = "DisplayName",
                FirstName   = "FirstName",
                LastName    = "LastName",
            });

            userId  = response.UserId;
            apiRepo = (IManageApiKeys)appHost.Resolve <IAuthRepository>();
            var apiKeys = apiRepo.GetUserApiKeys(userId);

            liveKey = apiKeys.First(x => x.Environment == "live");
            testKey = apiKeys.First(x => x.Environment == "test");
        }
Exemplo n.º 2
0
        public StatelessAuthTests()
        {
            //LogManager.LogFactory = new ConsoleLogFactory();
            appHost = CreateAppHost()
                      .Init()
                      .Start("http://*:2337/");

            var client   = GetClient();
            var response = client.Post(new Register
            {
                UserName    = "******",
                Password    = "******",
                Email       = "as@if{0}.com",
                DisplayName = "DisplayName",
                FirstName   = "FirstName",
                LastName    = "LastName",
            });

            userId  = response.UserId;
            apiRepo = (IManageApiKeys)appHost.Resolve <IAuthRepository>();
            var user1Client = GetClientWithUserPassword(alwaysSend: true);

            ApiKey = user1Client.Get(new GetApiKeys {
                Environment = "live"
            }).Results[0].Key;

            apiProvider = (ApiKeyAuthProvider)AuthenticateService.GetAuthProvider(ApiKeyAuthProvider.Name);

            response = client.Post(new Register
            {
                UserName    = "******",
                Password    = "******",
                Email       = "as2@if{0}.com",
                DisplayName = "DisplayName2",
                FirstName   = "FirstName2",
                LastName    = "LastName2",
            });
            userIdWithRoles = response.UserId;
            var user2Client = GetClientWithUserPassword(alwaysSend: true, userName: "******");

            ApiKeyWithRole = user2Client.Get(new GetApiKeys {
                Environment = "live"
            }).Results[0].Key;

            ListeningOn.CombineWith("/assignroles").AddQueryParam("authsecret", "secret")
            .PostJsonToUrl(new AssignRoles
            {
                UserName = "******",
                Roles    = new List <string> {
                    "TheRole"
                },
                Permissions = new List <string> {
                    "ThePermission"
                }
            }.ToJson());
        }
Exemplo n.º 3
0
        public StatelessAuthTests()
        {
            //LogManager.LogFactory = new ConsoleLogFactory();
            appHost = CreateAppHost()
                      .Init()
                      .Start("http://*:2337/");

            var client   = GetClient();
            var response = client.Post(new Register
            {
                UserName    = "******",
                Password    = "******",
                Email       = "as@if{0}.com",
                DisplayName = "DisplayName",
                FirstName   = "FirstName",
                LastName    = "LastName",
            });

            userId  = response.UserId;
            apiRepo = (IManageApiKeys)appHost.Resolve <IAuthRepository>();
            ApiKey  = apiRepo.GetUserApiKeys(userId).First(x => x.Environment == "test");

            apiProvider = (ApiKeyAuthProvider)AuthenticateService.GetAuthProvider(ApiKeyAuthProvider.Name);
        }
Exemplo n.º 4
0
 public ManageApiKeysAsyncWrapper(IManageApiKeys manageApiKeys) => this.manageApiKeys = manageApiKeys;