-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement User-Agent spec for transport (#1518)
This commit implements the User-Agent feature. Update User-Agent sent by the agent to match the spec. HttpClient parses apm-agent-dotnet/<version> (<service> <version>) as two separate User-Agent header values: apm-agent-dotnet/<version> (<service> <version>) - Refactor outcome steps to use ScenarioContext. - Introduce TestConfiguration to allow configuration to be provided a step at a time. - Collect all payloads sent to mock HttpMessageHandler. Co-authored-by: Russ Cam <[email protected]>
- Loading branch information
1 parent
afbc9e7
commit e953480
Showing
10 changed files
with
353 additions
and
120 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,37 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// 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 TechTalk.SpecFlow; | ||
|
||
namespace Elastic.Apm.Feature.Tests | ||
{ | ||
[Binding] | ||
public class ConfigurationSteps | ||
{ | ||
private readonly ScenarioContext _scenarioContext; | ||
|
||
public ConfigurationSteps(ScenarioContext scenarioContext) => _scenarioContext = scenarioContext; | ||
|
||
[When("^service name is not set$")] | ||
public void WhenServiceNameIsNotSet() { } | ||
|
||
[When("^service version is not set$")] | ||
public void WhenServiceVersionIsNotSet() { } | ||
|
||
[When("^service name is set to '(.*?)'$")] | ||
public void WhenServiceNameIsSetTo(string name) | ||
{ | ||
var configuration = _scenarioContext.Get<TestConfiguration>(); | ||
configuration.ServiceName = name; | ||
} | ||
|
||
[When("^service version is set to '(.*?)'$")] | ||
public void WhenServiceVersionIsSetTo(string version) | ||
{ | ||
var configuration = _scenarioContext.Get<TestConfiguration>(); | ||
configuration.ServiceVersion = version; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
test/Elastic.Apm.Feature.Tests/Features/user_agent.feature
This file contains 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,19 @@ | ||
Feature: Agent Transport User agent Header | ||
|
||
Scenario: Default user-agent | ||
Given an agent | ||
When service name is not set | ||
When service version is not set | ||
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]*' | ||
|
||
Scenario: User-agent with service name only | ||
Given an agent | ||
When service name is set to 'myService' | ||
When service version is not set | ||
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]* \(myService\)' | ||
|
||
Scenario: User-agent with service name and service version | ||
Given an agent | ||
When service name is set to 'myService' | ||
When service version is set to 'v42' | ||
Then the User-Agent header matches regex '^apm-agent-[a-z]+/[^ ]* \(myService v42\)' |
Oops, something went wrong.