<commit_before>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

namespace Nether.Web.IntegrationTests.Identity
{
    public class UserApiTests : WebTestBase
    {
        private HttpClient _client;

        [Fact]
        public async Task As_a_player_I_get_Forbidden_response_calling_GetUsers()
        {
            await AsPlayerAsync();
            await ResponseForGetAsync("/api/identity/users", hasStatusCode: HttpStatusCode.Forbidden);
        }

        private async Task<HttpResponseMessage> ResponseForGetAsync(string path, HttpStatusCode hasStatusCode)<commit_msg>Continue adding user api tests<commit_after>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

namespace Nether.Web.IntegrationTests.Identity
{
    public class UserApiTests : WebTestBase
    {
        private HttpClient _client;

        [Fact]
        public async Task As_a_player_I_get_Forbidden_response_calling_GetUsers()
        {
            await AsPlayerAsync();
            await ResponseForGetAsync("/api/identity/users", hasStatusCode: HttpStatusCode.Forbidden);
        }
        [Fact]
        public async Task As_a_player_I_get_Forbidden_response_calling_GetUser()
        {
            await AsPlayerAsync();
            await ResponseForGetAsync("/api/identity/users/123", hasStatusCode: HttpStatusCode.Forbidden);
        }
        // ... should we fill out the other requests to check permissions, or not?


        [Fact]
        public async Task As_an_admin_I_can_list_users()
        {
            await AsPlayerAsync();
            var response = await ResponseForGetAsync("/api/identity/users", hasStatusCode: HttpStatusCode.OK);
            dynamic responseContent = response.Content.ReadAsAsync<dynamic>();

            var users = ((IEnumerable<dynamic>)responseContent.users).ToList();
            Assert.NotNull(users);
            Assert.True(users.Count > 0);

            dynamic user = users[0];
            Assert.NotNull(user.userId);
            Assert.NotNull(user.role);
            Assert.NotNull(user._link);
        }




        private async Task<HttpResponseMessage> ResponseForGetAsync(string path, HttpStatusCode hasStatusCode)
{'fraction_non_alphanumeric': 0.08258258258258258, 'fraction_numerical': 0.0018768768768768769, 'mean_word_length': 2.98355754857997, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2401486', 'n_tokens_mistral': 687, 'n_tokens_neox': 700, 'n_words': 182}