diff --git a/MessagingService.IntegrationTests/Email/SendEmail.feature b/MessagingService.IntegrationTests/Email/SendEmail.feature
index 72d30bd..4c97522 100644
--- a/MessagingService.IntegrationTests/Email/SendEmail.feature
+++ b/MessagingService.IntegrationTests/Email/SendEmail.feature
@@ -2,6 +2,11 @@
Feature: SendEmail
Background:
+
+ Given I create the following api scopes
+ | Name | DisplayName | Description |
+ | messagingService | Messaging REST Scope | A scope for Messaging REST |
+
Given the following api resources exist
| ResourceName | DisplayName | Secret | Scopes | UserClaims |
| messagingService | Messaging REST | Secret1 | messagingService | |
diff --git a/MessagingService.IntegrationTests/Email/SendEmail.feature.cs b/MessagingService.IntegrationTests/Email/SendEmail.feature.cs
index 2535e67..604ef23 100644
--- a/MessagingService.IntegrationTests/Email/SendEmail.feature.cs
+++ b/MessagingService.IntegrationTests/Email/SendEmail.feature.cs
@@ -89,41 +89,52 @@ public virtual void FeatureBackground()
#line 4
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
+ "Name",
+ "DisplayName",
+ "Description"});
+ table1.AddRow(new string[] {
+ "messagingService",
+ "Messaging REST Scope",
+ "A scope for Messaging REST"});
+#line 6
+ testRunner.Given("I create the following api scopes", ((string)(null)), table1, "Given ");
+#line hidden
+ TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
"ResourceName",
"DisplayName",
"Secret",
"Scopes",
"UserClaims"});
- table1.AddRow(new string[] {
+ table2.AddRow(new string[] {
"messagingService",
"Messaging REST",
"Secret1",
"messagingService",
""});
-#line 5
- testRunner.Given("the following api resources exist", ((string)(null)), table1, "Given ");
+#line 10
+ testRunner.Given("the following api resources exist", ((string)(null)), table2, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId",
"ClientName",
"Secret",
"AllowedScopes",
"AllowedGrantTypes"});
- table2.AddRow(new string[] {
+ table3.AddRow(new string[] {
"serviceClient",
"Service Client",
"Secret1",
"messagingService",
"client_credentials"});
-#line 9
- testRunner.Given("the following clients exist", ((string)(null)), table2, "Given ");
+#line 14
+ testRunner.Given("the following clients exist", ((string)(null)), table3, "Given ");
#line hidden
- TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
"ClientId"});
- table3.AddRow(new string[] {
+ table4.AddRow(new string[] {
"serviceClient"});
-#line 13
- testRunner.Given("I have a token to access the messaging service resource", ((string)(null)), table3, "Given ");
+#line 18
+ testRunner.Given("I have a token to access the messaging service resource", ((string)(null)), table4, "Given ");
#line hidden
}
@@ -142,7 +153,7 @@ public virtual void SendEmail()
"PRTest"};
System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send Email", null, tagsOfScenario, argumentsOfScenario);
-#line 18
+#line 23
this.ScenarioInitialize(scenarioInfo);
#line hidden
bool isScenarioIgnored = default(bool);
@@ -165,26 +176,26 @@ public virtual void SendEmail()
#line 4
this.FeatureBackground();
#line hidden
- TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
+ TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
"FromAddress",
"ToAddresses",
"Subject",
"Body",
"IsHtml"});
- table4.AddRow(new string[] {
+ table5.AddRow(new string[] {
"fromaddress@testemail.com",
"toaddress1@testemail.com",
"Test Email 1",
"Test Body",
"true"});
- table4.AddRow(new string[] {
+ table5.AddRow(new string[] {
"fromaddress@testemail.com",
"toaddress1@testemail.com,toaddress2@testemail.com",
"Test Email 1",
"Test Body",
"true"});
-#line 19
- testRunner.Given("I send the following Email Messages", ((string)(null)), table4, "Given ");
+#line 24
+ testRunner.Given("I send the following Email Messages", ((string)(null)), table5, "Given ");
#line hidden
}
this.ScenarioCleanup();
diff --git a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
index c854b3d..ee2540c 100644
--- a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
+++ b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/MessagingService.IntegrationTests/SMS/SendSMS.feature b/MessagingService.IntegrationTests/SMS/SendSMS.feature
index 4bcc1a8..fc685f7 100644
--- a/MessagingService.IntegrationTests/SMS/SendSMS.feature
+++ b/MessagingService.IntegrationTests/SMS/SendSMS.feature
@@ -2,6 +2,11 @@
Feature: SendSMS
Background:
+
+ Given I create the following api scopes
+ | Name | DisplayName | Description |
+ | messagingService | Messaging REST Scope | A scope for Messaging REST |
+
Given the following api resources exist
| ResourceName | DisplayName | Secret | Scopes | UserClaims |
| messagingService | Messaging REST | Secret1 | messagingService | |
diff --git a/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs b/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs
index 2598a3a..9cdccdf 100644
--- a/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs
+++ b/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs
@@ -1,201 +1,3 @@
-// ------------------------------------------------------------------------------
-//
-// This code was generated by SpecFlow (https://www.specflow.org/).
-// SpecFlow Version:3.5.0.0
-// SpecFlow Generator Version:3.5.0.0
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// ------------------------------------------------------------------------------
-#region Designer generated code
-#pragma warning disable
-namespace MessagingService.IntegrationTests.SMS
-{
- using TechTalk.SpecFlow;
- using System;
- using System.Linq;
-
-
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")]
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [Xunit.TraitAttribute("Category", "base")]
- [Xunit.TraitAttribute("Category", "shared")]
- [Xunit.TraitAttribute("Category", "sms")]
- public partial class SendSMSFeature : object, Xunit.IClassFixture, System.IDisposable
- {
-
- private static TechTalk.SpecFlow.ITestRunner testRunner;
-
- private string[] _featureTags = new string[] {
- "base",
- "shared",
- "sms"};
-
- private Xunit.Abstractions.ITestOutputHelper _testOutputHelper;
-
-#line 1 "SendSMS.feature"
-#line hidden
-
- public SendSMSFeature(SendSMSFeature.FixtureData fixtureData, MessagingService_IntegrationTests_XUnitAssemblyFixture assemblyFixture, Xunit.Abstractions.ITestOutputHelper testOutputHelper)
- {
- this._testOutputHelper = testOutputHelper;
- this.TestInitialize();
- }
-
- public static void FeatureSetup()
- {
- testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
- TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "SMS", "SendSMS", null, ProgrammingLanguage.CSharp, new string[] {
- "base",
- "shared",
- "sms"});
- testRunner.OnFeatureStart(featureInfo);
- }
-
- public static void FeatureTearDown()
- {
- testRunner.OnFeatureEnd();
- testRunner = null;
- }
-
- public virtual void TestInitialize()
- {
- }
-
- public virtual void TestTearDown()
- {
- testRunner.OnScenarioEnd();
- }
-
- public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
- {
- testRunner.OnScenarioInitialize(scenarioInfo);
- testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(_testOutputHelper);
- }
-
- public virtual void ScenarioStart()
- {
- testRunner.OnScenarioStart();
- }
-
- public virtual void ScenarioCleanup()
- {
- testRunner.CollectScenarioErrors();
- }
-
- public virtual void FeatureBackground()
- {
-#line 4
-#line hidden
- TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
- "ResourceName",
- "DisplayName",
- "Secret",
- "Scopes",
- "UserClaims"});
- table5.AddRow(new string[] {
- "messagingService",
- "Messaging REST",
- "Secret1",
- "messagingService",
- ""});
-#line 5
- testRunner.Given("the following api resources exist", ((string)(null)), table5, "Given ");
-#line hidden
- TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
- "ClientId",
- "ClientName",
- "Secret",
- "AllowedScopes",
- "AllowedGrantTypes"});
- table6.AddRow(new string[] {
- "serviceClient",
- "Service Client",
- "Secret1",
- "messagingService",
- "client_credentials"});
-#line 9
- testRunner.Given("the following clients exist", ((string)(null)), table6, "Given ");
-#line hidden
- TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
- "ClientId"});
- table7.AddRow(new string[] {
- "serviceClient"});
-#line 13
- testRunner.Given("I have a token to access the messaging service resource", ((string)(null)), table7, "Given ");
-#line hidden
- }
-
- void System.IDisposable.Dispose()
- {
- this.TestTearDown();
- }
-
- [Xunit.SkippableFactAttribute(DisplayName="Send SMS")]
- [Xunit.TraitAttribute("FeatureTitle", "SendSMS")]
- [Xunit.TraitAttribute("Description", "Send SMS")]
- [Xunit.TraitAttribute("Category", "PRTest")]
- public virtual void SendSMS()
- {
- string[] tagsOfScenario = new string[] {
- "PRTest"};
- System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Send SMS", null, tagsOfScenario, argumentsOfScenario);
-#line 18
-this.ScenarioInitialize(scenarioInfo);
-#line hidden
- bool isScenarioIgnored = default(bool);
- bool isFeatureIgnored = default(bool);
- if ((tagsOfScenario != null))
- {
- isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
- }
- if ((this._featureTags != null))
- {
- isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
- }
- if ((isScenarioIgnored || isFeatureIgnored))
- {
- testRunner.SkipScenario();
- }
- else
- {
- this.ScenarioStart();
-#line 4
-this.FeatureBackground();
-#line hidden
- TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
- "Sender",
- "Destination",
- "Message"});
- table8.AddRow(new string[] {
- "TestSender",
- "07777777771",
- "TestSMSMessage"});
-#line 19
- testRunner.Given("I send the following SMS Messages", ((string)(null)), table8, "Given ");
-#line hidden
- }
- this.ScenarioCleanup();
- }
-
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")]
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class FixtureData : System.IDisposable
- {
-
- public FixtureData()
- {
- SendSMSFeature.FeatureSetup();
- }
-
- void System.IDisposable.Dispose()
- {
- SendSMSFeature.FeatureTearDown();
- }
- }
- }
-}
-#pragma warning restore
-#endregion
+#error Could not find a reference to SpecFlow in project 'MessagingService.IntegrationTests'.
+#error Please add the 'TechTalk.SpecFlow' package to the project and use MSBuild generation instead of using SpecFlowSingleFileGenerator.
+#error For more information see https://specflow.org/documentation/Generate-Tests-from-MsBuild/
\ No newline at end of file
diff --git a/MessagingService.IntegrationTests/Shared/SharedSteps.cs b/MessagingService.IntegrationTests/Shared/SharedSteps.cs
index 21c2b17..122e3ba 100644
--- a/MessagingService.IntegrationTests/Shared/SharedSteps.cs
+++ b/MessagingService.IntegrationTests/Shared/SharedSteps.cs
@@ -30,6 +30,32 @@ public SharedSteps(ScenarioContext scenarioContext,
this.TestingContext = testingContext;
}
+ [Given(@"I create the following api scopes")]
+ public async Task GivenICreateTheFollowingApiScopes(Table table)
+ {
+ foreach (TableRow tableRow in table.Rows)
+ {
+ CreateApiScopeRequest createApiScopeRequest = new CreateApiScopeRequest
+ {
+ Name = SpecflowTableHelper.GetStringRowValue(tableRow, "Name"),
+ Description = SpecflowTableHelper.GetStringRowValue(tableRow, "Description"),
+ DisplayName = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName")
+ };
+ var createApiScopeResponse =
+ await this.CreateApiScope(createApiScopeRequest, CancellationToken.None).ConfigureAwait(false);
+
+ createApiScopeResponse.ShouldNotBeNull();
+ createApiScopeResponse.ApiScopeName.ShouldNotBeNullOrEmpty();
+ }
+ }
+
+ private async Task CreateApiScope(CreateApiScopeRequest createApiScopeRequest,
+ CancellationToken cancellationToken)
+ {
+ CreateApiScopeResponse createApiScopeResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.CreateApiScope(createApiScopeRequest, cancellationToken).ConfigureAwait(false);
+ return createApiScopeResponse;
+ }
+
[Given(@"the following api resources exist")]
public async Task GivenTheFollowingApiResourcesExist(Table table)
{
diff --git a/MessagingService/MessagingService.csproj b/MessagingService/MessagingService.csproj
index 99b2e82..67d8b4f 100644
--- a/MessagingService/MessagingService.csproj
+++ b/MessagingService/MessagingService.csproj
@@ -8,11 +8,11 @@
+
-
diff --git a/MessagingService/Startup.cs b/MessagingService/Startup.cs
index 20f749b..f598d25 100644
--- a/MessagingService/Startup.cs
+++ b/MessagingService/Startup.cs
@@ -269,7 +269,7 @@ private void ConfigureMiddlewareServices(IServiceCollection services)
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
{
ValidateIssuer = true,
- ValidateAudience = true,
+ ValidateAudience = false,
ValidAudience = ConfigurationReader.GetValue("SecurityConfiguration", "ApiName"),
ValidIssuer = ConfigurationReader.GetValue("SecurityConfiguration", "Authority"),
};