Skip to content
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

Update error message strings #170

Merged
merged 2 commits into from
Nov 6, 2018
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
Expand Up @@ -176,7 +176,7 @@ public void GivenAFhirRequest_WhenExecutingAnActionWithoutAttributes_ThenExcepti
descriptor.MethodInfo = typeof(FilterTestsHelper).GetMethod("MethodWithNoAttribute");

var excp = Assert.Throws<NotSupportedException>(() => _filter.OnActionExecuting(executingContext));
Assert.Contains(excp.Message, "Audit Event Sub Type is not set for method MethodWithNoAttribute");
Assert.Contains(excp.Message, "Audit Event Sub Type is not set for method MethodWithNoAttribute.");
}
}
}
22 changes: 11 additions & 11 deletions src/Microsoft.Health.Fhir.Api/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/Microsoft.Health.Fhir.Api/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AuditEventSubTypeNotSet" xml:space="preserve">
<value>Audit Event Sub Type is not set for method {0}</value>
<value>Audit Event Sub Type is not set for method {0}.</value>
<comment>{0} is method name</comment>
</data>
<data name="BackToTop" xml:space="preserve">
<value>Back to top</value>
</data>
<data name="ContentTypeHeaderRequired" xml:space="preserve">
<value>The "content-type" header is required by the server</value>
<value>The "content-type" header is required.</value>
</data>
<data name="Forbidden" xml:space="preserve">
<value>Authorization failed</value>
<value>Authorization failed.</value>
</data>
<data name="GeneralInternalError" xml:space="preserve">
<value>There was an error processing your request.</value>
Expand All @@ -150,13 +150,13 @@
<value>The security configuration requires the authority to be set to an https address.</value>
</data>
<data name="ResourceAndIdRequired" xml:space="preserve">
<value>Both id and the resource are required</value>
<value>Both id and the resource are required.</value>
</data>
<data name="ResourceIdRequired" xml:space="preserve">
<value>There must be an id specified in the resource</value>
<value>Id must be specified in the resource.</value>
</data>
<data name="ResourceTypeMismatch" xml:space="preserve">
<value>Resource type mismatch</value>
<value>Resource type in the URL must match resourceType in the resource.</value>
</data>
<data name="ToggleNavigation" xml:space="preserve">
<value>Toggle navigation</value>
Expand All @@ -165,19 +165,19 @@
<value>Unable to obtain OpenID configuration.</value>
</data>
<data name="Unauthorized" xml:space="preserve">
<value>Authentication failed</value>
<value>Authentication failed.</value>
</data>
<data name="UnsupportedAcceptHeader" xml:space="preserve">
<value>The requested "accept" header is not supported by the server</value>
<value>The requested "accept" header is not supported.</value>
</data>
<data name="UnsupportedContentTypeHeader" xml:space="preserve">
<value>The requested "content-type" header is not supported by the server</value>
<value>The requested "content-type" header is not supported.</value>
</data>
<data name="UnsupportedFormatParameter" xml:space="preserve">
<value>The requested "_format" is not supported by the server</value>
<value>The requested "_format" parameter is not supported.</value>
</data>
<data name="UrlResourceIdMismatch" xml:space="preserve">
<value>The id in the URL must match the id in the resource</value>
<value>Id in the URL must match id in the resource.</value>
</data>
<data name="ViewNotFound" xml:space="preserve">
<value>View was not found.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void GivenASearchParameterDefinitionFileWithInvalidEntries_WhenBuilt_Then

[Theory]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/DocumentReference-relationship].component is null or empty.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Group-characteristic-value].component[1].definition.reference is null or empty, or is not pointing to a valid SearchParameter resource.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Observation-code-value-quantity].component[0] cannot be pointing to a composite SearchParameter.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Group-characteristic-value].component[1].definition.reference is null or empty or does not refer to a valid SearchParameter resource.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Observation-code-value-quantity].component[0] cannot refer to a composite SearchParameter.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Observation-code-value-string].component[1].expression is null or empty.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Observation-device].resource.base is not defined.")]
[InlineData("bundle.entry[http://hl7.org/fhir/SearchParameter/Observation-related].resource.expression is null or empty.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ public void GivenAValidAuthorizationConfiguration_WhenDeserailized_ThenReturnsEx
Assert.Equal(3, authorizationConfiguration.Roles.Count());
}

[Fact]
public void GivenAnInvalidAuthorizationConfigurationForRoleWithNoPermissions_WhenValidated_ThrowAppropriateValidationException()
{
var invalidAuthorizationConfiguration = Samples.GetJsonSample<AuthorizationConfiguration>("AuthConfigWithValidRoles");
invalidAuthorizationConfiguration.Roles[0].ResourcePermissions.Clear();

InvalidDefinitionException validationException = Assert.Throws<InvalidDefinitionException>(() => invalidAuthorizationConfiguration.ValidateRoles());

Assert.NotNull(validationException.Issues.SingleOrDefault(issueComp => issueComp.Diagnostics.Equals("Role 'clinician' must have one or more ResourcePermissions.")));
}

[Fact]
public void GivenAnInvalidAuthorizationConfigurationForRoleWithNoActions_WhenValidated_ThrowAppropriateValidationException()
{
var invalidAuthorizationConfiguration = Samples.GetJsonSample<AuthorizationConfiguration>("AuthConfigWithInvalidEntries");
InvalidDefinitionException validationException = Assert.Throws<InvalidDefinitionException>(() => invalidAuthorizationConfiguration.ValidateRoles());

Assert.NotNull(validationException.Issues.SingleOrDefault(issueComp => issueComp.Diagnostics.Equals("ResourcePermission for Role 'Nurse' does not have any Actions.")));
Assert.NotNull(validationException.Issues.SingleOrDefault(issueComp => issueComp.Diagnostics.Equals("Role 'Nurse' contains a ResourcePermission with no Actions.")));
}
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.Health.Fhir.Core/Features/Security/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex

if (ResourcePermissions.Count == 0)
{
yield return new ValidationResult(Core.Resources.ResourcePermissionEmpty);
yield return new ValidationResult(string.Format(CultureInfo.InvariantCulture, Core.Resources.ResourcePermissionEmpty, Name));
}
else
{
Expand Down
Loading