mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Create sso user api (#886)
* facilitate linking/unlinking existing users from an sso enabled org * added user_identifier to identity methods for sso * moved sso user delete method to account controller * fixed a broken test * Update AccountsController.cs * facilitate linking/unlinking existing users from an sso enabled org * added user_identifier to identity methods for sso * moved sso user delete method to account controller * fixed a broken test * added a token to the existing user sso link flow * added a token to the existing user sso link flow * fixed a typo * added an event log for unlink ssoUser records * fixed a merge issue * fixed a busted test * fixed a busted test * ran a formatter over everything & changed .vscode settings in .gitignore * chagned a variable to use string interpolation * removed a blank line * Changed TokenPurpose enum to a static class of strings * code review cleanups * formatting fix * Changed parameters & logging for delete sso user * changed th method used to get organization user for deleting sso user records Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Api.Controllers;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Enums;
|
||||
@ -12,21 +9,26 @@ using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Api.Test.Controllers
|
||||
{
|
||||
public class AccountsControllerTests : IDisposable
|
||||
{
|
||||
private readonly AccountsController _sut;
|
||||
|
||||
private readonly IUserService _userService;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly AccountsController _sut;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly ICipherRepository _cipherRepository;
|
||||
private readonly IFolderRepository _folderRepository;
|
||||
private readonly IOrganizationService _organizationService;
|
||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||
private readonly IPaymentService _paymentService;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly ISsoUserRepository _ssoUserRepository;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public AccountsControllerTests()
|
||||
{
|
||||
@ -34,17 +36,20 @@ namespace Bit.Api.Test.Controllers
|
||||
_userRepository = Substitute.For<IUserRepository>();
|
||||
_cipherRepository = Substitute.For<ICipherRepository>();
|
||||
_folderRepository = Substitute.For<IFolderRepository>();
|
||||
_organizationService = Substitute.For<IOrganizationService>();
|
||||
_organizationUserRepository = Substitute.For<IOrganizationUserRepository>();
|
||||
_paymentService = Substitute.For<IPaymentService>();
|
||||
_globalSettings = new GlobalSettings();
|
||||
_sut = new AccountsController(
|
||||
_userService,
|
||||
_userRepository,
|
||||
_globalSettings,
|
||||
_cipherRepository,
|
||||
_folderRepository,
|
||||
_organizationService,
|
||||
_organizationUserRepository,
|
||||
_paymentService,
|
||||
_globalSettings
|
||||
_ssoUserRepository,
|
||||
_userRepository,
|
||||
_userService
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,14 @@ namespace Bit.Core.Test.Services
|
||||
var paymentService = Substitute.For<IPaymentService>();
|
||||
var policyRepo = Substitute.For<IPolicyRepository>();
|
||||
var ssoConfigRepo = Substitute.For<ISsoConfigRepository>();
|
||||
var ssoUserRepo = Substitute.For<ISsoUserRepository>();
|
||||
var referenceEventService = Substitute.For<IReferenceEventService>();
|
||||
var globalSettings = Substitute.For<GlobalSettings>();
|
||||
|
||||
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
||||
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
||||
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
||||
ssoConfigRepo, referenceEventService, globalSettings);
|
||||
ssoConfigRepo, ssoUserRepo, referenceEventService, globalSettings);
|
||||
|
||||
var id = Guid.NewGuid();
|
||||
var userId = Guid.NewGuid();
|
||||
@ -93,13 +94,14 @@ namespace Bit.Core.Test.Services
|
||||
var paymentService = Substitute.For<IPaymentService>();
|
||||
var policyRepo = Substitute.For<IPolicyRepository>();
|
||||
var ssoConfigRepo = Substitute.For<ISsoConfigRepository>();
|
||||
var ssoUserRepo = Substitute.For<ISsoUserRepository>();
|
||||
var referenceEventService = Substitute.For<IReferenceEventService>();
|
||||
var globalSettings = Substitute.For<GlobalSettings>();
|
||||
|
||||
var orgService = new OrganizationService(orgRepo, orgUserRepo, collectionRepo, userRepo,
|
||||
groupRepo, dataProtector, mailService, pushNotService, pushRegService, deviceRepo,
|
||||
licenseService, eventService, installationRepo, appCacheService, paymentService, policyRepo,
|
||||
ssoConfigRepo, referenceEventService, globalSettings);
|
||||
ssoConfigRepo, ssoUserRepo, referenceEventService, globalSettings);
|
||||
|
||||
var id = Guid.NewGuid();
|
||||
var userId = Guid.NewGuid();
|
||||
|
Reference in New Issue
Block a user