Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div class="api-param-section expanded" data-param-section="">
<h2 class="section-header api-param-section-header" id="authentication" data-section="authentication" aria-label="Authentication">
<a class="headerlink api-param-section-title" href="#authentication">Authentication</a>
<button type="button" class="api-param-section-toggle" aria-expanded="true" aria-controls="authentication-list" aria-label="Toggle Authentication">
<span class="api-param-summary is-variants" data-param-summary="" data-param-more-noun="variant">
<span class="api-param-summary-list">
<code class="api-param-summary-item" data-name="Basic + Api key"></code>
</span>
<span class="api-param-more" data-param-more="" hidden="">
<span class="api-param-more-badge" data-param-more-count=""></span>
</span>
</span>
<span class="api-param-chevron" aria-hidden="true"></span>
</button>
</h2>
<div class="api-param-section-body" id="authentication-list">
<div>
<div class="api-authorization-panel">
<p>Send all of these together.</p>
<h3>Basic</h3>
<div class="highlight-http notranslate">
<div class="highlight">
<pre>
<code class="language-http">Authorization: Basic &lt;credentials&gt;</code>
</pre>
</div>
</div>
<h3>Api key</h3>
<div class="highlight-http notranslate">
<div class="highlight">
<pre>
<code class="language-http">X-Key: &lt;value&gt;</code>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="api-param-section expanded" data-param-section="">
<h2 class="section-header api-param-section-header" id="required-privileges" data-section="required-privileges" aria-label="Required privileges">
<a class="headerlink api-param-section-title" href="#required-privileges">Required privileges</a>
<button type="button" class="api-param-section-toggle" aria-expanded="true" aria-controls="required-privileges-list" aria-label="Toggle Required privileges">
<span class="api-param-summary is-all" data-param-summary="">
<span class="api-param-summary-list">
<code class="api-param-summary-item" data-name="integrations-all"></code>
<code class="api-param-summary-item" data-name="fleet-agent-policies-all"></code>
</span>
<span class="api-param-more" data-param-more="" hidden="">
<span class="api-param-more-badge" data-param-more-count=""></span>
</span>
</span>
<span class="api-param-chevron" aria-hidden="true"></span>
</button>
</h2>
<div class="api-param-section-body" id="required-privileges-list">
<dl class="property-list api-privileges">
<div class="prerequisite-item">
<dt>
<span class="privilege-label">Privileges</span>
<span class="api-type-badge">integrations-all</span>
<span class="privilege-join">and</span>
<span class="api-type-badge">fleet-agent-policies-all</span>
</dt>
</div>
</dl>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div class="api-param-section expanded" data-param-section="">
<h2 class="section-header api-param-section-header" id="authentication" data-section="authentication" aria-label="Authentication">
<a class="headerlink api-param-section-title" href="#authentication">Authentication</a>
<button type="button" class="api-param-section-toggle" aria-expanded="true" aria-controls="authentication-list" aria-label="Toggle Authentication">
<span class="api-param-summary is-variants" data-param-summary="" data-param-more-noun="variant">
<span class="api-param-summary-list">
<code class="api-param-summary-item" data-name="Basic + Api key"></code>
<code class="api-param-summary-item" data-name="Bearer"></code>
</span>
<span class="api-param-more" data-param-more="" hidden="">
<span class="api-param-more-badge" data-param-more-count=""></span>
</span>
</span>
<span class="api-param-chevron" aria-hidden="true"></span>
</button>
</h2>
<div class="api-param-section-body" id="authentication-list">
<div class="api-tabs api-authentication-tabs">
<input class="tabs-input" id="authentication-tab-0" name="authentication-tabs" type="radio" checked="checked" tabindex="0">
<label class="tabs-label" for="authentication-tab-0">Basic + Api key</label>
<div class="tabs-content api-authorization-panel">
<p>Send all of these together.</p>
<h3>Basic</h3>
<div class="highlight-http notranslate">
<div class="highlight">
<pre>
<code class="language-http">Authorization: Basic &lt;credentials&gt;</code>
</pre>
</div>
</div>
<h3>Api key</h3>
<div class="highlight-http notranslate">
<div class="highlight">
<pre>
<code class="language-http">X-Key: &lt;value&gt;</code>
</pre>
</div>
</div>
</div>
<input class="tabs-input" id="authentication-tab-1" name="authentication-tabs" type="radio" tabindex="0">
<label class="tabs-label" for="authentication-tab-1">Bearer</label>
<div class="tabs-content api-authorization-panel">
<div class="highlight-http notranslate">
<div class="highlight">
<pre>
<code class="language-http">Authorization: Bearer &lt;token&gt;</code>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Elastic.ApiExplorer.Operations;
using Elastic.ApiExplorer.Operations._Partials;
using Microsoft.AspNetCore.Html;
using Nullean.Snapshots.Html;
using RazorSlices;

namespace Elastic.ApiExplorer.Tests;
Expand Down Expand Up @@ -54,10 +55,8 @@ public async Task Render_RequirementWithTwoSchemes_SharesOneTabAndSaysToSendBoth
new AuthRequirement([Scheme("bearer", "Bearer", "Authorization: Bearer <token>")])
);

html.Should().Contain("<label class=\"tabs-label\" for=\"authentication-tab-0\">Basic &#x2B; Api key</label>");
html.Should().Contain("<label class=\"tabs-label\" for=\"authentication-tab-1\">Bearer</label>");
html.Should().MatchHtmlSnapshot();
html.Should().Contain("Send all of these together.");
html.Should().Contain("<h3>Basic</h3>").And.Contain("<h3>Api key</h3>");
}

[Test]
Expand All @@ -68,28 +67,17 @@ public async Task Render_OneRequirementWithTwoSchemes_HasNoTabsAndShowsBothSchem
Scheme("key", "Api key", "X-Key: <value>")
]));

html.Should().NotContain("api-tabs");
html.Should().NotContain("tabs-label");
html.Should().Contain("Send all of these together.");
html.Should().Contain("<h3>Basic</h3>").And.Contain("<h3>Api key</h3>");
html.Should().Contain("Authorization: Basic &lt;credentials&gt;").And.Contain("X-Key: &lt;value&gt;");
html.Should().MatchHtmlSnapshot();
html.Should().NotContain("api-tabs", "a single requirement needs no tabs");
}

[Test]
public async Task Render_PrivilegesNeededTogether_AreSummarisedAsSeparateNamesJoinedWithPlus()
{
var html = await RenderPrivileges(new PrivilegeRow("Privileges", ["integrations-all", "fleet-agent-policies-all"], "and"));

html.Should().Contain("data-param-section");
html.Should().Contain("id=\"required-privileges\"");
html.Should().Contain("<code class=\"api-param-summary-item\" data-name=\"integrations-all\"></code>");
html.Should().Contain("<code class=\"api-param-summary-item\" data-name=\"fleet-agent-policies-all\"></code>");
html.Should().Contain("api-param-summary is-all");
html.Should().Contain("id=\"required-privileges-list\"");
html.Should().Contain("id=\"required-privileges-list\">", "the body has no hidden attribute, so it shows on load");
html.Should().NotContain("id=\"required-privileges-list\" hidden");
html.Should().MatchRegex("aria-expanded=\"true\"\\s+aria-controls=\"required-privileges-list\"");
html.Should().Contain("<span class=\"api-type-badge\">integrations-all</span>", "the rows are still listed in the body");
html.Should().MatchHtmlSnapshot();
html.Should().NotContain("id=\"required-privileges-list\" hidden", "the body has no hidden attribute, so it shows on load");
}

[Test]
Expand Down
Loading