internal static async Task <(Authenticator, Session)> CreateTestApp( string secret, string password, SafeApp.Core.AuthReq authReq) { var auth = await Authenticator.CreateAccountAsync(secret, password); var(_, reqMsg) = await Session.EncodeAuthReqAsync(authReq); var ipcReq = await auth.DecodeIpcMessageAsync(reqMsg); Assert.That(ipcReq, Is.TypeOf <AuthIpcReq>()); var authIpcReq = ipcReq as AuthIpcReq; var resMsg = await auth.EncodeAuthRespAsync(authIpcReq, true); var ipcResponse = await Session.DecodeIpcMessageAsync(resMsg); Assert.That(ipcResponse, Is.TypeOf <SafeApp.Core.AuthIpcMsg>()); var authResponse = ipcResponse as SafeApp.Core.AuthIpcMsg; Assert.That(authResponse, Is.Not.Null); var session = await Session.AppConnectAsync(authReq.App.Id, resMsg); return(auth, session); }
public static async Task <(Authenticator, Session)> CreateTestApp(string secret, string password) { var authReq = new SafeApp.Core.AuthReq { App = new SafeApp.Core.AppExchangeInfo { Id = GetRandomString(10), Name = GetRandomString(5), Scope = null, Vendor = GetRandomString(5) }, AppContainer = true, Containers = new List <SafeApp.Core.ContainerPermissions>() }; return(await CreateTestApp(secret, password, authReq)); }
public static SafeApp.Core.AuthReq CreateAuthRequest() { var authReq = new SafeApp.Core.AuthReq { App = new SafeApp.Core.AppExchangeInfo { Id = GetRandomString(10), Name = GetRandomString(5), Scope = null, Vendor = GetRandomString(5) }, AppContainer = true, Containers = new List <SafeApp.Core.ContainerPermissions>() }; return(authReq); }
public static SafeApp.Core.ContainersReq SetContainerPermission( SafeApp.Core.AuthReq authReq, string containerType) { var containerRequest = new SafeApp.Core.ContainersReq { App = authReq.App, Containers = new List <SafeApp.Core.ContainerPermissions> { new SafeApp.Core.ContainerPermissions { ContName = containerType, Access = new SafeApp.Core.PermissionSet { Read = true, Insert = true, Delete = true, ManagePermissions = true, Update = true } } } }; return(containerRequest); }