Beispiel #1
0
        public static SafeApp.Utilities.AuthReq CreateAuthRequest()
        {
            var authReq = new SafeApp.Utilities.AuthReq
            {
                App = new SafeApp.Utilities.AppExchangeInfo
                {
                    Id = GetRandomString(10), Name = GetRandomString(5), Scope = null, Vendor = GetRandomString(5)
                },
                AppContainer = true,
                Containers   = new List <SafeApp.Utilities.ContainerPermissions>()
            };

            return(authReq);
        }
Beispiel #2
0
        public static async Task <(Authenticator, Session)> CreateTestApp(string secret, string password, string invitation)
        {
            var authReq = new SafeApp.Utilities.AuthReq
            {
                App = new SafeApp.Utilities.AppExchangeInfo
                {
                    Id = GetRandomString(10), Name = GetRandomString(5), Scope = null, Vendor = GetRandomString(5)
                },
                AppContainer = true,
                Containers   = new List <SafeApp.Utilities.ContainerPermissions>()
            };

            return(await CreateTestApp(secret, password, invitation, authReq));
        }
Beispiel #3
0
        public async Task <SafeApp.Session> CreateAppSessionAsync(SafeApp.Utilities.AuthReq authReq)
        {
            var(_, reqMsg) = await SafeApp.Session.EncodeAuthReqAsync(authReq);

            var ipcReq = await _authenticator.DecodeIpcMessageAsync(reqMsg);

            var authIpcReq = ipcReq as AuthIpcReq;
            var resMsg     = await _authenticator.EncodeAuthRespAsync(authIpcReq, true);

            var ipcResponse = await SafeApp.Session.DecodeIpcMessageAsync(resMsg);

            var authResponse = ipcResponse as SafeApp.Utilities.AuthIpcMsg;

            var session = await SafeApp.Session.AppRegisteredAsync(authReq.App.Id, authResponse.AuthGranted);

            return(session);
        }
Beispiel #4
0
        public static SafeApp.Utilities.ContainersReq SetContainerPermission(SafeApp.Utilities.AuthReq authReq, string containerType)
        {
            var containerRequest = new SafeApp.Utilities.ContainersReq
            {
                App        = authReq.App,
                Containers = new List <SafeApp.Utilities.ContainerPermissions>
                {
                    new SafeApp.Utilities.ContainerPermissions
                    {
                        ContName = containerType,
                        Access   = new SafeApp.Utilities.PermissionSet
                        {
                            Read = true, Insert = true, Delete = true, ManagePermissions = true, Update = true
                        }
                    }
                }
            };

            return(containerRequest);
        }
Beispiel #5
0
        internal static async Task <(Authenticator, Session)> CreateTestApp(string secret, string password, string invitation, SafeApp.Utilities.AuthReq authReq)
        {
            var auth = await Authenticator.CreateAccountAsync(secret, password, invitation);

            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.Utilities.AuthIpcMsg>());

            var authResponse = ipcResponse as SafeApp.Utilities.AuthIpcMsg;

            Assert.That(authResponse, Is.Not.Null);

            var session = await Session.AppRegisteredAsync(authReq.App.Id, authResponse.AuthGranted);

            return(auth, session);
        }