예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }