Пример #1
0
        public void GetAllUsersFromAllDomainsTest()
        {
            OAuth2DomainUser userA = new OAuth2DomainUser()
            {
                domain = domainNameString, userName = "******"
            };
            OAuth2DomainUser userB = new OAuth2DomainUser()
            {
                domain = "domainB", userName = "******"
            };

            consumer.SetUser(domainNameString, userA);
            var domainB = new OAuth2Domain()
            {
                domain = "domainB"
            };

            consumer.SetDomain(domainB);
            consumer.SetUser("domainB", userB);

            List <OAuth2DomainUser> result = consumer.GetAllUsers().ToList();

            Assert.AreEqual(result.Count, 3);
            Assert.Contains(domainUserObj, result);
            Assert.Contains(userA, result);
            Assert.Contains(userB, result);
        }
Пример #2
0
        public void SetDomainTest()
        {
            string newDomainName = "newDomain";

            var newDomain = new OAuth2Domain()
            {
                domain = newDomainName
            };

            consumer.SetDomain(newDomain);

            Assert.IsTrue(consumer.DomainExists(newDomainName));
        }
Пример #3
0
        public void GetAllDomainsTest()
        {
            var newDomain = new OAuth2Domain()
            {
                domain = "newDomain"
            };

            consumer.SetDomain(newDomain);

            List <OAuth2Domain> domains = consumer.GetAllDomains().ToList();

            Assert.Contains(newDomain, domains);
            Assert.Contains(domainObj, domains);
        }
Пример #4
0
        public void RemoveDomainTest()
        {
            string newDomainName = "newDomain";

            var newDomain = new OAuth2Domain()
            {
                domain = newDomainName
            };

            consumer.SetDomain(newDomain);

            consumer.RemoveDomain(domainNameString);

            Assert.IsFalse(consumer.DomainExists(domainNameString));
            Assert.IsTrue(consumer.DomainExists(newDomainName));
        }
Пример #5
0
        public void Init()
        {
            //manually set up the dataStore
            dataStore = new TestDataStore();

            tokenInfoObj = new OAuth2TokenInfo()
            {
                token       = tokenResponseObj,
                tokenString = tokenStringString
            };

            tokenResponseObj = new TokenResponse()
            {
                AccessToken = accessTokenString
            };

            clientSecretsObj = new ClientSecrets()
            {
                ClientId = clientIdString, ClientSecret = clientSecretString
            };

            domainUserObj = new OAuth2DomainUser()
            {
                clientSecrets = clientSecretsObj, domain = domainNameString, userName = userNameString
            };

            domainUserObj.tokenAndScopesByApi.Add(apiString, tokenInfoObj);

            domainObj = new OAuth2Domain()
            {
                defaultUser = userNameString
            };

            domainObj.users.Add(userNameString, domainUserObj);

            var internalInfo = new OAuth2Info()
            {
                defaultDomain = domainNameString, defaultClientSecrets = clientSecretsObj
            };

            internalInfo.domains.Add(domainNameString, domainObj);

            dataStore.internalInfo = internalInfo;

            consumer = new OAuth2InfoConsumer(dataStore);
        }