diff --git a/src/Nest/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenResponse.cs b/src/Nest/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenResponse.cs index 469f8300881..07fd708ff91 100644 --- a/src/Nest/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenResponse.cs +++ b/src/Nest/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenResponse.cs @@ -2,7 +2,9 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using System.Collections.Generic; using System.Runtime.Serialization; +using Elasticsearch.Net; namespace Nest { @@ -19,5 +21,46 @@ public class GetUserAccessTokenResponse : ResponseBase [DataMember(Name ="type")] public string Type { get; set; } + + [DataMember(Name = "authentication")] + public Authentication Authentication { get; set; } + } + + public class Authentication + { + [DataMember(Name = "email")] + public string Email { get; internal set; } + + [DataMember(Name = "full_name")] + public string FullName { get; internal set; } + + [DataMember(Name = "metadata")] + public IReadOnlyDictionary Metadata { get; internal set; } + = EmptyReadOnly.Dictionary; + + [DataMember(Name = "roles")] + public IReadOnlyCollection Roles { get; internal set; } + = EmptyReadOnly.Collection; + + [DataMember(Name = "username")] + public string Username { get; internal set; } + + [DataMember(Name = "authentication_realm")] + public AuthenticationRealmInfo AuthenticationRealm { get; internal set; } + + [DataMember(Name = "lookup_realm")] + public AuthenticationRealmInfo LookupRealm { get; internal set; } + + [DataMember(Name = "authentication_type")] + public string AuthenticationType { get; internal set; } + } + + public class AuthenticationRealmInfo + { + [DataMember(Name = "name")] + public string Name { get; internal set; } + + [DataMember(Name = "type")] + public string Type { get; internal set; } } } diff --git a/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs b/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs index d63caebc922..bf626ea6faa 100644 --- a/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs +++ b/tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs @@ -7,6 +7,8 @@ using Elasticsearch.Net; using FluentAssertions; using Nest; +using Tests.Configuration; +using Tests.Core.Extensions; using Tests.Framework.EndpointTests; using Tests.Framework.EndpointTests.TestState; using static Elastic.Elasticsearch.Ephemeral.ClusterAuthentication; @@ -63,6 +65,13 @@ protected override void ExpectResponse(GetUserAccessTokenResponse response) response.Type.Should().NotBeNullOrEmpty().And.Be("Bearer"); response.ExpiresIn.Should().BeGreaterThan(0); response.Scope.Should().Be("full"); + + if (TestConfiguration.Instance.InRange(">=7.11.0")) + { + response.Authentication.Should().NotBeNull(); + response.Authentication.Username.Should().NotBeNullOrEmpty(); + response.Authentication.Roles.Count.Should().BeGreaterThan(0); + } } }