Moving micasa 1.5 trunk to Novell forge.

This commit is contained in:
Cameron (Kamran) Mashayekhi
2005-10-11 19:51:00 +00:00
parent 082db33275
commit efe0a5e13c
691 changed files with 116628 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
#if DEBUG
using System;
using System.Text;
using System.Collections;
//using System.InvalidOperationException;
using NUnit.Framework;
using sscs.common;
using sscs.verbs;
namespace sscs.cache
{
[TestFixture]
public class TestRequestParser
{
RequestParser reqParser = null;
[SetUp]
public void Init()
{
reqParser = new RequestParser();
}
[Test]
[ExpectedException(typeof(FormatException))]
public void TestNullRequest()
{
// SSVerb verb = reqParser.ParseRequest(null);
reqParser.ParseRequest(null);
}
[Test]
public void TestParseRequest()
{
// byte[] buf = new byte[1024];
//buf[0] = 1;
// buf[1] = 1;
int i =1;
byte[] dummy = BitConverter.GetBytes(i);
SSVerb verb = reqParser.ParseRequest(dummy);
Assert.AreEqual("sscs.verbs.OpenSecretStore", verb.GetVerbName());
i = 18;
dummy = BitConverter.GetBytes(i);
verb = reqParser.ParseRequest(dummy);
Assert.AreEqual("sscs.verbs.GetUserState", verb.GetVerbName());
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestParseRequestInvalid()
{
byte[] buf = new byte[1024] ;
buf[0] = 25;
buf[1] = 25;
// SSVerb verb = reqParser.ParseRequest(buf);
reqParser.ParseRequest(buf);
}
}
}
#endif

View File

@@ -0,0 +1,154 @@
#if DEBUG
using System;
using System.Text;
using System.Collections;
//using System.InvalidOperationException;
using NUnit.Framework;
using sscs.common;
using sscs.cache;
namespace sscs.common
{
[TestFixture]
public class TestSessionManager
{
User theuser = null;
UnixUserIdentifier UserId = null;
UnixUserIdentifier root = null;
SecretStore mysec = null;
SecretStore anothersec = null;
KeyChain mykc1 = null;
KeyChain mykc2 = null;
byte[] secbyte1 = null;
byte[] secbyte2 = null;
Secret mysecret1 = null;
Secret mysecret2 = null;
SessionManager sesman ;
[SetUp]
public void Init()
{
sesman = SessionManager.GetSessionManager;
mykc1 = new KeyChain("k1");
mykc2 = new KeyChain("k2");
mysecret1 = new Secret();
mysecret2 = new Secret();
mysecret1.SetKey("key1");
mysecret2.SetKey("key2");
secbyte1 = Encoding.ASCII.GetBytes("NOVELL");
secbyte2 = Encoding.ASCII.GetBytes("IBM");
mysecret1.SetValue(secbyte1);
mysecret2.SetValue(secbyte2);
mykc1.AddSecret(mysecret1);
mykc2.AddSecret(mysecret2);
UserId = new UnixUserIdentifier(420);
root = new UnixUserIdentifier(0);
//theuser = new UnixUser(UserId);
}
[Test]
public void TestCreateUserSession()
{
anothersec = SessionManager.CreateUserSession(root);
mysec = SessionManager.CreateUserSession(UserId);
//Assert.AreEqual(1, mysec.getRefCount());
//Assert.AreEqual(1, anothersec.getRefCount());
Assert.AreEqual(true, SessionManager.CheckIfUserSessionExists(UserId));
Assert.AreEqual(true, SessionManager.CheckIfUserSessionExists(root));
}
[Test]
public void TestAddtoSession()
{
SecretStore s1 = SessionManager.GetUserSecretStore(UserId);
SecretStore s2 = SessionManager.GetUserSecretStore(root);
s1.AddKeyChain(mykc1);
s2.AddKeyChain(mykc2);
s1 = SessionManager.GetUserSecretStore(UserId);
s2 = SessionManager.GetUserSecretStore(root);
KeyChain returnK1 = s1.GetKeyChain("k1");
Secret returnS1 = returnK1.GetSecret("key1");
KeyChain returnK2 = s2.GetKeyChain("k2");
Secret returnS2 = returnK2.GetSecret("key2");
Assert.AreEqual("NOVELL", Encoding.ASCII.GetString(returnS1.GetValue()));
Assert.AreEqual("IBM",Encoding.ASCII.GetString(returnS2.GetValue()) );
}
[Test]
[ExpectedException(typeof(KeyChainDoesNotExistException))]
public void TestInvalidAccess()
{
SecretStore s1 = SessionManager.GetUserSecretStore(UserId);
//SecretStore s2 = SessionManager.GetUserSecretStore(root);
s1.GetKeyChain("k2");
}
[Test]
public void TestRemoveUserSession()
{
SessionManager.RemoveUserSession(UserId, true);
Assert.AreEqual(false, SessionManager.CheckIfUserSessionExists(UserId));
//TBD :Make the ref count more than one and delete call remove sesison once.
//The call it once more.. only second time it should remove the session entry.
}
}
}
#endif