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
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<AssemblyName>ElasticSearch.Net.Aws.IntegrationTests</AssemblyName>
<PackageId>ElasticSearch.Net.Aws.IntegrationTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -17,16 +17,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.*" />
<PackageReference Include="NUnit" Version="3.7.*" />
<PackageReference Include="NEST" Version="6.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="NEST" Version="7.0.0-alpha2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Random_encoded_url_should_work()
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
var client = new ElasticLowLevelClient(config);
var response = client.Get<BytesResponse>(randomString, string.Join(",", Enumerable.Repeat(randomString, 2)), randomString);
var response = client.Get<BytesResponse>(randomString, randomString);
Assert.AreEqual(404, response.HttpStatusCode.GetValueOrDefault(-1));
}

Expand All @@ -55,7 +55,7 @@ public void Asterisk_encoded_url_should_work()
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
var client = new ElasticLowLevelClient(config);
var response = client.Get<BytesResponse>("index*", "type", "id");
var response = client.Get<BytesResponse>("index*", "id");
Assert.AreEqual(404, response.HttpStatusCode.GetValueOrDefault(-1));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void Setup()
var httpConnection = new AwsHttpConnection(Region);
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
config.DisableDirectStreaming();
_client = new ElasticLowLevelClient(config);
_indexName = $"unittest_{Guid.NewGuid().ToString("n")}";
}
Expand All @@ -36,10 +37,10 @@ public void TearDown()
public void SimplePost_should_work()
{
var id = Guid.NewGuid().ToString("n");
var response = _client.Create<VoidResponse>(_indexName, "test", id, PostData.Serializable(new { message = "Hello, World!" }));
Assert.AreEqual(true, response.Success);
var getResponse = _client.Get<StringResponse>(_indexName, "test", id);
Assert.AreEqual(true, getResponse.Success);
var response = _client.Create<VoidResponse>(_indexName, id, PostData.Serializable(new { message = "Hello, World!" }));
Assert.AreEqual(true, response.Success, response.DebugInformation);
var getResponse = _client.Get<StringResponse>(_indexName, id);
Assert.AreEqual(true, getResponse.Success, getResponse.DebugInformation);
StringAssert.Contains("Hello, World!", getResponse.Body);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<AssemblyName>ElasticSearch.Net.Aws.Tests</AssemblyName>
<PackageId>ElasticSearch.Net.Aws.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -17,21 +17,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.*" />
<PackageReference Include="NUnit" Version="3.7.*" />
<PackageReference Include="NEST" Version="6.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Elasticsearch.Net" Version="6.0.1" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@ public void SetUp()
{
var encoding = new UTF8Encoding(false);
_sampleBody = encoding.GetBytes("Action=ListUsers&Version=2010-05-08");
#if NETCOREAPP
var request = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, "https://iam.amazonaws.com/");
request.Content = new System.Net.Http.ByteArrayContent(_sampleBody);
request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
request.Headers.TryAddWithoutValidation("X-Amz-Date", "20110909T233600Z");
_sampleRequest = new HttpRequestMessageAdapter(request);
#elif NET461
var request = System.Net.WebRequest.CreateHttp("https://iam.amazonaws.com/");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
request.Headers["X-Amz-Date"] = "20110909T233600Z";
_sampleRequest = new HttpWebRequestAdapter(request);
#endif
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,12 @@ public AwsHttpConnection() : this(
{
}

#if !NETSTANDARD
protected override System.Net.HttpWebRequest CreateHttpWebRequest(RequestData requestData)
{
var request = base.CreateHttpWebRequest(requestData);
SignRequest(new HttpWebRequestAdapter(request), requestData);
return request;
}
#else
protected override HttpRequestMessage CreateHttpRequestMessage(RequestData requestData)
{
var request = base.CreateHttpRequestMessage(requestData);
SignRequest(new HttpRequestMessageAdapter(request), requestData);
return request;
}
#endif

private void SignRequest(IRequest request, RequestData requestData)
{
Expand All @@ -74,7 +65,16 @@ private void SignRequest(IRequest request, RequestData requestData)
}
}
}
var credentials = _credentials.GetCredentials();
ImmutableCredentials credentials;
try
{
credentials = _credentials.GetCredentials();
}
catch (Exception e)
{
throw new Exception("Unable to retrieve credentials required to sign the request.", e);
}

if (credentials == null)
{
throw new Exception("Unable to retrieve credentials required to sign the request.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>6.1.0</VersionPrefix>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<VersionPrefix>7.0.0</VersionPrefix>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>Elasticsearch.Net.Aws</AssemblyName>
<PackageId>Elasticsearch.Net.Aws</PackageId>
<PackageVersion>6.1.0</PackageVersion>
Expand All @@ -14,9 +14,9 @@
<PackageReleaseNotes>Use AWSSDK.Core to get credentials instead of custom code.</PackageReleaseNotes>
<PackageTags>elasticsearch elastic search aws amazon</PackageTags>
<RepositoryUrl>https://github.com/bcuff/elasticsearch-net-aws</RepositoryUrl>
<AssemblyVersion>6.1.0</AssemblyVersion>
<FileVersion>6.1.0</FileVersion>
<Version>6.1.0</Version>
<AssemblyVersion>7.0.0</AssemblyVersion>
<FileVersion>7.0.0</FileVersion>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
Expand All @@ -26,21 +26,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="3.3.17.9" />
<PackageReference Include="Elasticsearch.Net" Version="6.*" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.Configuration" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.1.1" />
<PackageReference Include="AWSSDK.Core" Version="3.3.*" />
<PackageReference Include="Elasticsearch.Net" Version="7.0.0-alpha2" />
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elasticsearch.Net is up to beta1 now, this PR will need updating
https://www.nuget.org/packages/Elasticsearch.Net/7.0.0-beta1

</ItemGroup>

</Project>

This file was deleted.

7 changes: 2 additions & 5 deletions src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/SignV4Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,15 @@ private static void WriteSignedHeaders(Dictionary<string, string> canonicalHeade
}
}

#if !NETSTANDARD
private static NameValueCollection ParseQueryString(string query) =>
System.Web.HttpUtility.ParseQueryString(query);
#else

private static NameValueCollection ParseQueryString(string query) =>
Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(query)
.Aggregate(new NameValueCollection(), (col, kv) =>
{
kv.Value.ToList().ForEach(v => col.Add(kv.Key, v));
return col;
});
#endif

public static string GetCanonicalQueryString(this Uri uri)
{
if (string.IsNullOrWhiteSpace(uri.Query)) return string.Empty;
Expand Down