-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement security.get_builtin_privileges #4536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/Nest/XPack/Security/Privileges/GetBuiltinPrivileges/GetBuiltinPrivilegesRequest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Nest | ||
{ | ||
[MapsApi("security.get_builtin_privileges.json")] | ||
public partial interface IGetBuiltinPrivilegesRequest { } | ||
|
||
public partial class GetBuiltinPrivilegesRequest { } | ||
|
||
public partial class GetBuiltinPrivilegesDescriptor { } | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Nest/XPack/Security/Privileges/GetBuiltinPrivileges/GetBuiltinPrivilegesResponse.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
using Elasticsearch.Net; | ||
using Elasticsearch.Net.Utf8Json; | ||
|
||
namespace Nest | ||
{ | ||
[DataContract] | ||
public class GetBuiltinPrivilegesResponse : ResponseBase | ||
{ | ||
[DataMember(Name = "cluster")] | ||
public IReadOnlyCollection<string> Cluster { get; internal set; } = EmptyReadOnly<string>.Collection; | ||
|
||
[DataMember(Name = "index")] | ||
public IReadOnlyCollection<string> Index { get; internal set; } = EmptyReadOnly<string>.Collection; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/Tests/XPack/Security/GetBuiltinPrivileges/GetBuiltinPrivilegesApiTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Elastic.Xunit.XunitPlumbing; | ||
using Elasticsearch.Net; | ||
using Nest; | ||
using Tests.Core.Extensions; | ||
using Tests.Core.ManagedElasticsearch.Clusters; | ||
using Tests.Framework.EndpointTests; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.XPack.Security.GetBuiltinPrivileges | ||
{ | ||
[SkipVersion("<7.7.0", "Introduced in 7.7.0")] | ||
public class GetBuiltinPrivilegesApiTests | ||
: ApiIntegrationTestBase<XPackCluster, GetBuiltinPrivilegesResponse, IGetBuiltinPrivilegesRequest, GetBuiltinPrivilegesDescriptor, | ||
GetBuiltinPrivilegesRequest> | ||
{ | ||
public GetBuiltinPrivilegesApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override bool ExpectIsValid => true; | ||
protected override int ExpectStatusCode => 200; | ||
|
||
protected override Func<GetBuiltinPrivilegesDescriptor, IGetBuiltinPrivilegesRequest> Fluent => d => d; | ||
protected override HttpMethod HttpMethod => HttpMethod.GET; | ||
|
||
protected override GetBuiltinPrivilegesRequest Initializer => new GetBuiltinPrivilegesRequest(); | ||
|
||
protected override bool SupportsDeserialization => false; | ||
|
||
protected override string UrlPath => $"/_security/privilege/_builtin"; | ||
|
||
protected override LazyResponses ClientUsage() => Calls( | ||
(client, f) => client.Security.GetBuiltinPrivileges(f), | ||
(client, f) => client.Security.GetBuiltinPrivilegesAsync(f), | ||
(client, r) => client.Security.GetBuiltinPrivileges(r), | ||
(client, r) => client.Security.GetBuiltinPrivilegesAsync(r) | ||
); | ||
|
||
protected override GetBuiltinPrivilegesDescriptor NewDescriptor() => new GetBuiltinPrivilegesDescriptor(); | ||
|
||
protected override void ExpectResponse(GetBuiltinPrivilegesResponse response) => response.ShouldBeValid(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/Tests/XPack/Security/GetBuiltinPrivileges/GetBuiltinPrivilegesUrlTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Threading.Tasks; | ||
using Elastic.Xunit.XunitPlumbing; | ||
using Nest; | ||
using Tests.Framework.EndpointTests; | ||
using static Tests.Framework.EndpointTests.UrlTester; | ||
|
||
namespace Tests.XPack.Security.GetBuiltinPrivileges | ||
{ | ||
public class GetBuiltinPrivilegesUrlTests : UrlTestsBase | ||
{ | ||
[U] public override async Task Urls() => | ||
await GET("/_security/privilege/_builtin") | ||
.Fluent(c => c.Security.GetBuiltinPrivileges()) | ||
.Request(c => c.Security.GetBuiltinPrivileges(new GetBuiltinPrivilegesRequest())) | ||
.FluentAsync(c => c.Security.GetBuiltinPrivilegesAsync()) | ||
.RequestAsync(c => c.Security.GetBuiltinPrivilegesAsync(new GetBuiltinPrivilegesRequest())); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.