public void GetScalarClaimValue_GivenUnfindableClaim_ReturnsDefaulValue() { // Arrange string defaultValue = "12321"; // Act string lookupValue = ClaimsHelper.GetScalarClaimValue <string>(user, ClaimTypes.Country, defaultValue); // Assert Assert.True(lookupValue.Equals(defaultValue), "With an unfindable claim the default value must be returned."); }
public void GetScalarClaimValue_GivenNullClaimsPrinicple_ReturnsDefaulValue() { // Arrange string defaultValue = "12321"; // Act string lookupValue = ClaimsHelper.GetScalarClaimValue <string>(null, ClaimTypes.NameIdentifier, defaultValue); // Assert Assert.True(lookupValue.Equals(defaultValue), "With a null Claims Principle the default value must be returned."); }
public async override Task <IActionResult> UpdateTeamAsync([FromRoute, Required] Guid teamId, [FromBody] TeamSubmit teamSubmit) { if (teamId == Guid.Empty || teamSubmit.Uuid == Guid.Empty) { return(BadRequest()); } var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); return(Ok(await teamService.UpdateAsync(teamSubmit, loggedOnUser))); }
public override async Task <IActionResult> UpdateLdapAuthenticationModeAsync([FromRoute, Required] Guid ldapAuthenticationModeId, [FromBody] LdapAuthenticationModeSubmit ldapAuthenticationModeSubmit) { if (ldapAuthenticationModeId == Guid.Empty || ldapAuthenticationModeSubmit.Uuid == Guid.Empty) { return(BadRequest()); } var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); return(Ok(await authenticationModeService.UpdateAsync(ldapAuthenticationModeSubmit, loggedOnUser))); }
public void GetScalarClaimValue_GivenFindableClaim_ReturnsClaimValue() { // Arrange string defaultValue = "12321"; // Act string lookupValue = ClaimsHelper.GetScalarClaimValue <string>(user, ClaimTypes.NameIdentifier, defaultValue); // Assert Assert.True(lookupValue.Equals(userId), "With a findable claim the claim value must be returned."); Assert.False(lookupValue.Equals(defaultValue), "With a findable claim the default value must NOT be returned."); }
public async override Task <IActionResult> ApplySecurityContractAsync([FromBody] SecurityContract securityContract) { if (securityContract == null) { return(BadRequest()); } var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); await securityContractService.ApplySecurityContractDefinitionAsync(securityContract, loggedOnUser); return(NoContent()); }
public async override Task <IActionResult> ValidateSecurityContractAsync([FromBody] SecurityContract securityContract) { if (securityContract == null) { return(BadRequest()); } var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); // This service will throw a custom exception (which is not really an exception) for returning the response. await securityContractService.ApplySecurityContractDefinitionAsync(securityContract, loggedOnUser, true); return(NoContent()); }
public async override Task <IActionResult> CreateTermsOfServiceAsync([FromBody] TermsOfServiceSubmit termsOfServiceSubmit) { var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); return(Ok(await termsOfServiceService.CreateAsync(termsOfServiceSubmit, loggedOnUser))); }
public override async Task <IActionResult> CreateLdapAuthenticationModeAsync([FromBody] LdapAuthenticationModeSubmit ldapAuthenticationModeSubmit) { var loggedOnUser = ClaimsHelper.GetScalarClaimValue <Guid>(User, ClaimTypes.NameIdentifier, Guid.Empty); return(Ok(await authenticationModeService.CreateAsync(ldapAuthenticationModeSubmit, loggedOnUser))); }