Esempio n. 1
0
        public void RestoreTokenTest()
        {
            SecurityWS target = new SecurityWS();
            String     token  = "UNKNOW";

            target.RestoreToken(userId, token);
        }
Esempio n. 2
0
        public void GenerateOneTimeTokenAndRigenerate()
        {
            SecurityWS    target    = new SecurityWS();
            KeyLengthEnum keyLength = KeyLengthEnum.Sixteen;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token = String.Empty;
            Exception     ex    = null;

            // Generazione del token
            token = target.GenerateOneTimeToken(userId, keyLength, initializationVectorLength);

            // Salvataggio del token nel context
            this.TestContext.Properties["token"] = token;

            // Richiesta di generazione di un ulteriore token per lo stesso utente
            try
            {
                token = target.GenerateOneTimeToken(userId, keyLength, initializationVectorLength);
            }
            catch (Exception e)
            {
                ex = e;
            }

            //this.RemoveTokenTest();

            if (ex != null)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public void RemoveUnknowTokenTest()
        {
            SecurityWS target = new SecurityWS();
            String     token  = "NotValidToken";

            target.RemoveToken(userId, token);
        }
Esempio n. 4
0
        public void GenerateExplicitTokenRestoreTokenAndRerestorTokenTest()
        {
            SecurityWS    target    = new SecurityWS();
            KeyLengthEnum keyLength = KeyLengthEnum.Sixteen;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token         = String.Empty;
            String        restoredToken = String.Empty;

            // Generazione del token
            token = target.GenerateExplicitToken(userId, keyLength, initializationVectorLength);

            // Sleep per 100 millisecondi
            Thread.Sleep(100);

            // Ripristino del token
            restoredToken = target.RestoreToken(userId, token);

            // Sleep per 5000 millisecondi
            Thread.Sleep(5000);

            // Richiesta di ripristino del token
            restoredToken = target.RestoreToken(userId, token);

            // Salvataggio del token nel context
            this.TestContext.Properties["token"] = token;

            Assert.IsFalse(String.IsNullOrEmpty(restoredToken));

            //this.RemoveTokenTest();
        }
Esempio n. 5
0
        public void StringIsNotATokenTest()
        {
            SecurityWS target = new SecurityWS();
            String     token  = "test://thisIsNotAToken";
            Boolean    result = false;

            result = target.IsAuthToken(token);

            Assert.IsFalse(result);
        }
Esempio n. 6
0
        public void StringIsAuthTokenTest()
        {
            SecurityWS target = new SecurityWS();
            String     token  = "SSO=thisIsAToken";
            Boolean    result = false;

            result = target.IsAuthToken(token);

            Assert.IsTrue(result);
        }
Esempio n. 7
0
        public void GenerateOneTimeTokenForUnknowUser()
        {
            SecurityWS    target    = new SecurityWS();
            String        userId    = "UNKNOW";
            KeyLengthEnum keyLength = KeyLengthEnum.ThirtyTwo;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token = String.Empty;

            // Generazione del token
            token = target.GenerateOneTimeToken(userId, keyLength, initializationVectorLength);
        }
Esempio n. 8
0
        public void ContextCleanUp()
        {
            // Se non c'è la proprietà "token" non bisogna fare il cleanup
            if (!this.TestContext.Properties.Contains("token"))
            {
                return;
            }

            SecurityWS target = new SecurityWS();

            target.Timeout = System.Threading.Timeout.Infinite;

            String token = this.TestContext.Properties["token"].ToString();

            target.RemoveToken(userId, token);
        }
Esempio n. 9
0
        public void GenerateOneTimeTokenRestoreTokenAndRerestorTokenTest()
        {
            SecurityWS    target    = new SecurityWS();
            KeyLengthEnum keyLength = KeyLengthEnum.Sixteen;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token         = String.Empty;
            String        restoredToken = String.Empty;

            // Generazione del token
            token = target.GenerateOneTimeToken(userId, keyLength, initializationVectorLength);

            // Richiesta di ripristino del token
            restoredToken = target.RestoreToken(userId, token);

            // Ririprino del token
            restoredToken = target.RestoreToken(userId, token);
        }
Esempio n. 10
0
        public void GenerateOneTimeTokenAndRestoreTokenTest()
        {
            SecurityWS target = new SecurityWS();

            target.Timeout = System.Threading.Timeout.Infinite;
            KeyLengthEnum keyLength = KeyLengthEnum.Sixteen;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token         = String.Empty;
            String        restoredToken = String.Empty;

            // Generazione del token
            token = target.GenerateOneTimeToken(userId, keyLength, initializationVectorLength);

            // Richiesta di ripristino del token
            restoredToken = target.RestoreToken(userId, token);

            Assert.IsFalse(String.IsNullOrEmpty(restoredToken));
        }
Esempio n. 11
0
        public void GenerateExplicitTokenRestoreTokenAndRerestorToken2Test()
        {
            SecurityWS    target    = new SecurityWS();
            KeyLengthEnum keyLength = KeyLengthEnum.Sixteen;
            KeyLengthEnum initializationVectorLength = KeyLengthEnum.ThirtyTwo;
            String        token         = String.Empty;
            String        restoredToken = String.Empty;

            // Generazione del token
            token = target.GenerateExplicitToken(userId, keyLength, initializationVectorLength);

            // Sleep per 100 millisecondi
            Thread.Sleep(100);

            // Ripristino del token
            restoredToken = target.RestoreToken(userId, token);

            // Invalidazione del token
            target.RemoveToken(userId, token);

            // Richiesta di ripristino del token
            restoredToken = target.RestoreToken(userId, token);
        }
Esempio n. 12
0
 public void SecurityWSConstructorTest()
 {
     SecurityWS target = new SecurityWS();
 }