public async Task Member()
        {
            var task = await _tasksApi.CreateTaskCronAsync(GenerateName("it task"), TaskFlux, "0 2 * * *", _organization);

            var members = await _tasksApi.GetMembersAsync(task);

            Assert.AreEqual(0, members.Count);

            var user = await _usersApi.CreateUserAsync(GenerateName("Luke Health"));

            var resourceMember = await _tasksApi.AddMemberAsync(user, task);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceMember.RoleEnum.Member);

            members = await _tasksApi.GetMembersAsync(task);

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual(members[0].Id, user.Id);
            Assert.AreEqual(members[0].Name, user.Name);
            Assert.AreEqual(members[0].Role, ResourceMember.RoleEnum.Member);
            await _tasksApi.DeleteMemberAsync(user, task);

            members = await _tasksApi.GetMembersAsync(task);

            Assert.AreEqual(0, members.Count);
        }
Exemple #2
0
        public async Task Member()
        {
            var organization = await _organizationsApi.CreateOrganizationAsync(GenerateName("Constant Pro"));

            var members = await _organizationsApi.GetMembersAsync(organization);

            Assert.AreEqual(0, members.Count);

            var user = await _usersApi.CreateUserAsync(GenerateName("Luke Health"));

            var resourceMember = await _organizationsApi.AddMemberAsync(user, organization);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceMember.RoleEnum.Member);

            members = await _organizationsApi.GetMembersAsync(organization);

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual(members[0].Id, user.Id);
            Assert.AreEqual(members[0].Name, user.Name);
            Assert.AreEqual(members[0].Role, ResourceMember.RoleEnum.Member);

            await _organizationsApi.DeleteMemberAsync(user, organization);

            members = await _organizationsApi.GetMembersAsync(organization);

            Assert.AreEqual(0, members.Count);
        }
Exemple #3
0
        public async Task Member()
        {
            var scraper = await _scraperTargetsApi
                          .CreateScraperTargetAsync(GenerateName("InfluxDB scraper"), "http://localhost:9999", _bucket.Id,
                                                    _organization.Id);

            var members = await _scraperTargetsApi.GetMembersAsync(scraper);

            Assert.AreEqual(0, members.Count);

            var user = await _usersApi.CreateUserAsync(GenerateName("Luke Health"));

            var resourceMember = await _scraperTargetsApi.AddMemberAsync(user, scraper);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceMember.RoleEnum.Member);

            members = await _scraperTargetsApi.GetMembersAsync(scraper);

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual(members[0].Id, user.Id);
            Assert.AreEqual(members[0].Name, user.Name);
            Assert.AreEqual(members[0].Role, ResourceMember.RoleEnum.Member);

            await _scraperTargetsApi.DeleteMemberAsync(user, scraper);

            members = await _scraperTargetsApi.GetMembersAsync(scraper);

            Assert.AreEqual(0, members.Count);
        }
        public async Task Member()
        {
            var bucket = await _bucketsApi.CreateBucketAsync(GenerateName("robot sensor"), RetentionRule(), _organization);

            var members = await _bucketsApi.GetMembersAsync(bucket);

            Assert.AreEqual(0, members.Count);

            var user = await _usersApi.CreateUserAsync(GenerateName("Luke Health"));

            var resourceMember = await _bucketsApi.AddMemberAsync(user, bucket);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceMember.RoleEnum.Member);

            members = await _bucketsApi.GetMembersAsync(bucket);

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual(members[0].Id, user.Id);
            Assert.AreEqual(members[0].Name, user.Name);
            Assert.AreEqual(members[0].Role, ResourceMember.RoleEnum.Member);

            await _bucketsApi.DeleteMemberAsync(user, bucket);

            members = await _bucketsApi.GetMembersAsync(bucket);

            Assert.AreEqual(0, members.Count);
        }
        public async Task Member()
        {
            var telegrafConfig = await _telegrafsApi
                                 .CreateTelegrafAsync(GenerateName("tc"), "test-config", _organization, 1_000,
                                                      new List <TelegrafRequestPlugin> {
                NewCpuPlugin(), NewOutputPlugin()
            });

            var members = await _telegrafsApi.GetMembersAsync(telegrafConfig);

            Assert.AreEqual(0, members.Count);

            var user = await _usersApi.CreateUserAsync(GenerateName("Luke Health"));

            var resourceMember = await _telegrafsApi.AddMemberAsync(user, telegrafConfig);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceMember.RoleEnum.Member);

            members = await _telegrafsApi.GetMembersAsync(telegrafConfig);

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual(members[0].Id, user.Id);
            Assert.AreEqual(members[0].Name, user.Name);
            Assert.AreEqual(members[0].Role, ResourceMember.RoleEnum.Member);

            await _telegrafsApi.DeleteMemberAsync(user, telegrafConfig);

            members = await _telegrafsApi.GetMembersAsync(telegrafConfig);

            Assert.AreEqual(0, members.Count);
        }
        public async Task CreateUser()
        {
            var userName = GenerateName("John Ryzen");

            var user = await _usersApi.CreateUserAsync(userName);

            Assert.IsNotNull(user);
            Assert.IsNotEmpty(user.Id);
            Assert.AreEqual(user.Name, userName);

            var links = user.Links;

            Assert.IsNotNull(links);
            Assert.AreEqual(links.Self, $"/api/v2/users/{user.Id}");
            Assert.AreEqual(links.Logs, $"/api/v2/users/{user.Id}/logs");
        }
        public async Task CreateUser()
        {
            var userName = GenerateName("John Ryzen");

            var user = await _usersApi.CreateUserAsync(userName);

            Assert.IsNotNull(user);
            Assert.IsNotEmpty(user.Id);
            Assert.AreEqual(user.Name, userName);

            var links = user.Links;

            Assert.IsNotNull(links);
            Assert.AreEqual(links.Self, $"/api/v2/users/{user.Id}");
            // TODO https://github.com/influxdata/influxdb/issues/18389
            // Assert.AreEqual(links.Logs, $"/api/v2/users/{user.Id}/logs");
        }
Exemple #8
0
        public override async Task <ActionResult <CreateAccountResponse> > HandleAsync(
            [FromBody] CreateAccountRequest request,
            CancellationToken cancellationToken = default)
        {
            var sessionConfiguration = await _finApiService.BuildClientSessionConfiguration(cancellationToken);

            var clientApi = new UsersApi(sessionConfiguration);

            var account = request.Adapt <UserAccount>();
            await _databaseContext.UserAccounts.AddAsync(account, cancellationToken);

            await _databaseContext.SaveChangesAsync(cancellationToken);

            var userCreateParams = account.Adapt <UserCreateParams>();
            var response         = await clientApi.CreateUserAsync(userCreateParams, cancellationToken);

            var userSession = await _finApiService.Login(response.Id, response.Password, cancellationToken);

            var accessToken  = _tokenService.GenerateToken(account, userSession.RefreshToken);
            var refreshToken = _tokenService.GenerateRefreshToken();

            return(Ok(new CreateAccountResponse(accessToken, refreshToken)));
        }