public void GivenXelement_DropBox_ShouldHaveContructorAndDefaultValuiesSet()
        {
            const string conStr = @"<Source ID=""2aa3fdba-e0c3-47dd-8dd5-e6f24aaf5c7a"" Name=""test server"" Type=""Dev2Server"" ConnectionString=""AppServerUri=http://178.63.172.163:3142/dsf;WebServerPort=3142;AuthenticationType=Public;UserName=;Password="" Version=""1.0"" ResourceType=""Server"" ServerID=""51a58300-7e9d-4927-a57b-e5d700b11b55"">
  <TypeOf>Dev2Server</TypeOf>
  <DisplayName>test server</DisplayName>
  <Category>WAREWOLF SERVERS</Category>
  <Signature xmlns=""http://www.w3.org/2000/09/xmldsig#"">
    <SignedInfo>
      <CanonicalizationMethod Algorithm=""http://www.w3.org/TR/2001/REC-xml-c14n-20010315"" />
      <SignatureMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#rsa-sha1"" />
      <Reference URI="""">
        <Transforms>
          <Transform Algorithm=""http://www.w3.org/2000/09/xmldsig#enveloped-signature"" />
        </Transforms>
        <DigestMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#sha1"" />
        <DigestValue>1ia51dqx+BIMQ4QgLt+DuKtTBUk=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>Wqd39EqkFE66XVETuuAqZveoTk3JiWtAk8m1m4QykeqY4/xQmdqRRSaEfYBr7EHsycI3STuILCjsz4OZgYQ2QL41jorbwULO3NxAEhu4nrb2EolpoNSJkahfL/N9X5CvLNwpburD4/bPMG2jYegVublIxE50yF6ZZWG5XiB6SF8=</SignatureValue>
  </Signature>
</Source>";

            var         element     = XElement.Parse(conStr);
            OauthSource oauthSource = new DropBoxSource(element);

            Assert.IsNotNull(oauthSource);
            var xElement = oauthSource.ToXml();

            Assert.IsNotNull(xElement);
        }
        public IOAuthSource FetchSource(Guid resourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(resourceID);
            var db   = new DropBoxSource(xaml.ToXElement());

            return(db);
        }
Esempio n. 3
0
        public void ToStringEmptyObjectExpected()
        {
            var    testDropBoxSource             = new DropBoxSource();
            string actualSerializedDropBoxSource = testDropBoxSource.ToString();
            string expected = JsonConvert.SerializeObject(testDropBoxSource);

            Assert.AreEqual(expected, actualSerializedDropBoxSource);
        }
Esempio n. 4
0
        public void DropBoxSource_ToString_EmptyObject_AreEqual_ExpectedTrue()
        {
            var testDropBoxSource             = new DropBoxSource();
            var actualSerializedDropBoxSource = testDropBoxSource.ToString();
            var expected = JsonConvert.SerializeObject(testDropBoxSource);

            Assert.AreEqual(expected, actualSerializedDropBoxSource);
        }
Esempio n. 5
0
        public void ToStringFullySetupObjectExpectedJsonSerializedObjectReturnedAsString()
        {
            DropBoxSource testDropBoxSource           = SetupDefaultDropBoxSource();
            string        actualDropBoxSourceToString = testDropBoxSource.ToString();
            string        expected = JsonConvert.SerializeObject(testDropBoxSource);

            Assert.AreEqual(expected, actualDropBoxSourceToString);
        }
        public void OauthSource_ToXml_ShouldContructorAndDefaultValuiesSet()
        {
            OauthSource oauthSource = new DropBoxSource();

            Assert.IsNotNull(oauthSource);
            var xElement = oauthSource.ToXml();

            Assert.IsNotNull(xElement);
        }
Esempio n. 7
0
        public void WfApplicationUtils_DispatchDebugState_GivenValidParamsAndIntergoateOutputs_ShouldWriteUsingDebugDispactcher_GetResourceForDatalist()
        {
            //---------------Set up test pack-------------------
            var catLog = new Mock <IResourceCatalog>();

            catLog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new Resource
            {
                DataList = new StringBuilder()
            });

            IResource dropBoxSource = new DropBoxSource
            {
                AppKey      = "Key",
                AccessToken = "token",
                DataList    = new StringBuilder("<DataList></DataList>")
            };

            catLog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(dropBoxSource);

            var wfApplicationUtils = new WfApplicationUtils();
            var envMock            = new Mock <IExecutionEnvironment>();
            var debugDispatcher    = new Mock <IDebugDispatcher>();
            var debugState         = new DebugState {
                StateType = StateType.Start
            };

            debugDispatcher.Setup(dispatcher => dispatcher.Write(new WriteArgs {
                debugState = debugState, isTestExecution = It.IsAny <bool>(), isDebugFromWeb = It.IsAny <bool>(), testName = It.IsAny <string>(), isRemoteInvoke = It.IsAny <bool>(), remoteInvokerId = It.IsAny <string>(), parentInstanceId = It.IsAny <string>(), remoteDebugItems = It.IsAny <IList <IDebugState> >()
            }));
            var mock = new Mock <Func <IDebugDispatcher> >();

            mock.Setup(func => func()).Returns(() => debugDispatcher.Object);
            var mockObj = new Mock <IDSFDataObject>();

            mockObj.Setup(o => o.Environment).Returns(envMock.Object);
            mockObj.Setup(o => o.IsDebugMode()).Returns(true);
            var privateObject = new PrivateObject(wfApplicationUtils);

            privateObject.SetField("_getDebugDispatcher", mock.Object);
            privateObject.SetField("_lazyCat", catLog.Object);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                wfApplicationUtils.DispatchDebugState(mockObj.Object, StateType.Start, out var error);
                var state = debugState;
                debugDispatcher.Verify(dispatcher => dispatcher.Write(new WriteArgs {
                    debugState = state, isTestExecution = It.IsAny <bool>(), isDebugFromWeb = It.IsAny <bool>(), testName = It.IsAny <string>(), isRemoteInvoke = It.IsAny <bool>(), remoteInvokerId = It.IsAny <string>(), parentInstanceId = It.IsAny <string>(), remoteDebugItems = It.IsAny <IList <IDebugState> >()
                }));
                catLog.Verify(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>()));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void OauthSource_Ctor_Construct_ExpectSource()
        {
            //------------Setup for test--------------------------
            var oauthSource = new DropBoxSource();

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual(null, oauthSource.AccessToken);
            Assert.AreEqual(null, oauthSource.AppKey);
        }
        public void OauthSource_ShouldContructorAndDefaultValuiesSet()
        {
            OauthSource oauthSource = new DropBoxSource();

            Assert.IsNotNull(oauthSource);
            Assert.IsTrue(oauthSource.IsSource);
            Assert.IsFalse(oauthSource.IsService);
            Assert.IsFalse(oauthSource.IsFolder);
            Assert.IsFalse(oauthSource.IsReservedService);
            Assert.IsFalse(oauthSource.IsServer);
            Assert.IsFalse(oauthSource.IsResourceVersion);
        }
Esempio n. 10
0
        public void DispatchDebugState_GivenValidParamsAndIntergoateOutputs_ShouldWriteUsingDebugDispactcher_GetResourceForDatalist()
        {
            //---------------Set up test pack-------------------
            var catLog = new Mock <IResourceCatalog>();

            catLog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new Resource()
            {
                DataList = new StringBuilder()
            });

            IResource dropBoxSource = new DropBoxSource()
            {
                AppKey = "Key", AccessToken = "token"
            };

            dropBoxSource.DataList = new StringBuilder("<DataList></DataList>");
            catLog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(dropBoxSource);

            var wfApplicationUtils = new WfApplicationUtils();
            var envMock            = new Mock <IExecutionEnvironment>();
            var debugDispatcher    = new Mock <IDebugDispatcher>();
            var debugState         = new DebugState {
                StateType = StateType.Start
            };

            debugDispatcher.Setup(dispatcher => dispatcher.Write(debugState, It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>()));
            var mock = new Mock <Func <IDebugDispatcher> >();

            mock.Setup(func => func()).Returns(() => debugDispatcher.Object);
            var mockObj = new Mock <IDSFDataObject>();

            mockObj.Setup(o => o.Environment).Returns(envMock.Object);
            mockObj.Setup(o => o.IsDebugMode()).Returns(true);
            var privateObject = new PrivateObject(wfApplicationUtils);

            privateObject.SetField("_getDebugDispatcher", mock.Object);
            privateObject.SetField("_lazyCat", catLog.Object);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                wfApplicationUtils.DispatchDebugState(mockObj.Object, StateType.Start, false, string.Empty, out ErrorResultTO error, DateTime.Now, false, true);
                var state = debugState;
                debugDispatcher.Verify(dispatcher => dispatcher.Write(state, It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>()));
                catLog.Verify(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>()));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            //---------------Test Result -----------------------
        }
Esempio n. 11
0
 public void WhenISelectAsTheReadSource(string sourceName)
 {
     if (sourceName == "Drop")
     {
         var oauthSource = new DropBoxSource()
         {
             ResourceName = "Drop",
             AppKey       = "sourceKey",
             AccessToken  = "fgklkgjfkngnf"
         };
         GetViewModel().SelectedSource = oauthSource;
     }
 }
Esempio n. 12
0
        DropBoxSource SetupDefaultDropBoxSource()
        {
            var testDropBoxSource = new DropBoxSource
            {
                ResourceID   = Guid.NewGuid(),
                AppKey       = "",
                AccessToken  = "",
                ResourceName = "TestResource",
                ResourceType = "DropBoxSource"
            };

            return(testDropBoxSource);
        }
Esempio n. 13
0
        public void DropBoxSource_AppKey_CannotBeEmpty()
        {
            //------------Setup for test--------------------------
            var dbSource = new DropBoxSource
            {
                AppKey      = "",
                AccessToken = ""
            };
            //------------Execute Test---------------------------
            var appKey = dbSource.AppKey;

            //------------Assert Results-------------------------
            StringAssert.Contains(appKey, "");
        }
Esempio n. 14
0
        public void DropBoxSource_XML_Constractor_Initialise_ExpectTrue()
        {
            //------------------------Arrange-------------------------
            var element = XElement.Parse(conStr);
            //------------------------Act-----------------------------
            var dropBoxSource = new DropBoxSource(element);

            //------------------------Assert--------------------------
            Assert.AreEqual("", dropBoxSource.AccessToken);
            Assert.AreEqual("", dropBoxSource.AppKey);
            Assert.AreEqual("", dropBoxSource.AuthorRoles);
            Assert.AreEqual("test server", dropBoxSource.ResourceName);
            Assert.AreEqual("DropBoxSource", dropBoxSource.ResourceType);
        }
Esempio n. 15
0
        public void DropBoxSource_AppKey_And_AccessToken_Equals_ExpectTrue()
        {
            //------------------------Arrange-------------------------
            var element = XElement.Parse(conStr);
            //------------------------Act-----------------------------
            var mockOAuthSource = new Mock <IOAuthSource>();

            mockOAuthSource.Setup(o => o.AppKey).Returns("");
            mockOAuthSource.Setup(o => o.AccessToken).Returns("");

            var dropBoxSource = new DropBoxSource(element);

            var isDropboxSource = dropBoxSource.Equals(mockOAuthSource.Object);

            //------------------------Assert--------------------------
            Assert.IsTrue(isDropboxSource);
        }
        public void OauthSource_Ctor_FromXML_Construct_ExpectSource()
        {
            //------------Setup for test--------------------------
            var oauthSource = new DropBoxSource(XElement.Parse(@"<Source ID=""00000000-0000-0000-0000-000000000000"" Name="""" ResourceType=""OauthSource"" IsValid=""false"" ConnectionString=""AccessToken=secret;AppKey=key"" Type=""OauthSource"">
  <DisplayName></DisplayName>
  <Category></Category>
  <AuthorRoles></AuthorRoles>
  <ErrorMessages />
  <TypeOf>OauthSource</TypeOf>
</Source>"));

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual(oauthSource.AccessToken, "secret");
            Assert.AreEqual(oauthSource.AppKey, "key");
        }
Esempio n. 17
0
        public void ToXmlEmptyObjectExpectedXElementContainingNoInformationRegardingSource()
        {
            var      testDropBoxSource = new DropBoxSource();
            XElement expectedXml       = testDropBoxSource.ToXml();

            IEnumerable <XAttribute> attrib     = expectedXml.Attributes();
            IEnumerator <XAttribute> attribEnum = attrib.GetEnumerator();

            while (attribEnum.MoveNext())
            {
                if (attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }
Esempio n. 18
0
        public void DropBoxSource_Other_IsNull_Equals_ExpectFalse()
        {
            //------------------------Arrange-------------------------
            var element = XElement.Parse(conStr);
            //------------------------Act-----------------------------
            var mockOAuthSource = new Mock <IOAuthSource>();

            mockOAuthSource.Setup(o => o.AppKey).Returns("");
            mockOAuthSource.Setup(o => o.AccessToken).Returns("");

            var dropBoxSource = new DropBoxSource(element);

            var isDropboxSource = dropBoxSource.Equals(null);

            //------------------------Assert--------------------------
            Assert.IsFalse(isDropboxSource);
        }
Esempio n. 19
0
        public void DropBoxSource_ToXmlEmptyObject_XElementWithNoInformation_AreEqual_ExpectTrue()
        {
            var testDropBoxSource = new DropBoxSource();
            var expectedXml       = testDropBoxSource.ToXml();

            var attrib     = expectedXml.Attributes();
            var attribEnum = attrib.GetEnumerator();

            while (attribEnum.MoveNext())
            {
                if (attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save OAuth Source");
                StringBuilder resourceDefinition;

                values.TryGetValue("OAuthSource", out resourceDefinition);

                StringBuilder savePath;
                values.TryGetValue("savePath", out savePath);

                var src = serializer.Deserialize <IOAuthSource>(resourceDefinition);

                IResource res = null;

                switch (src.GetType().Name)
                {
                case "DropBoxSource":
                    res = new DropBoxSource
                    {
                        ResourceID   = src.ResourceID,
                        AppKey       = src.AppKey,
                        AccessToken  = src.AccessToken,
                        ResourceName = src.ResourceName
                    };
                    break;
                }

                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, res, savePath?.ToString());
                ServerExplorerRepo.UpdateItem(res);
                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
        public void OauthSource_ToXML_Construct_ExpectPropertiesSet()
        {
            //------------Setup for test--------------------------
            var oauthSource = new DropBoxSource()
            {
                AppKey = "key", AccessToken = "secret"
            };

            //------------Execute Test---------------------------
            var outxml = oauthSource.ToXml();
            //------------Assert Results-------------------------
            var readOauthSource = new DropBoxSource(outxml)
            {
                AppKey      = "key",
                AccessToken = "secret"
            };

            var conStringAttr = outxml.Attribute("ConnectionString");

            Assert.IsNotNull(conStringAttr);
            Assert.IsTrue(conStringAttr.Value.IsBase64());
        }
Esempio n. 22
0
        public void TestFromModel()
        {
            //arrange
            IOAuthSource dropBoxSource = new DropBoxSource()
            {
                ResourcePath = "test path", ResourceName = "test resource", AppKey = "test app key", AccessToken = "test token"
            };

            _manageOAuthSourceViewModel.Types = new List <string>()
            {
                "test provider"
            };

            //act
            _manageOAuthSourceViewModel.FromModel(dropBoxSource);

            //assert
            Assert.AreEqual(_manageOAuthSourceViewModel.Path, "test path");
            Assert.AreEqual(_manageOAuthSourceViewModel.ResourceName, "test resource");
            Assert.AreEqual(_manageOAuthSourceViewModel.AppKey, "test app key");
            Assert.AreEqual(_manageOAuthSourceViewModel.AccessToken, "test token");
            Assert.AreEqual(_manageOAuthSourceViewModel.SelectedOAuthProvider, "test provider");
        }
        public void FindServiceShape_GivenResource_ShouldReturnShape()
        {
            //---------------Set up test pack-------------------
            var       wfApplicationUtils = new WfApplicationUtils();
            var       privateObject      = new PrivateObject(wfApplicationUtils);
            var       catLog             = new Mock <IResourceCatalog>();
            IResource dropBoxSource      = new DropBoxSource()
            {
                AppKey = "Key", AccessToken = "token"
            };

            dropBoxSource.DataList = new StringBuilder("SomeValue");
            catLog.Setup(catalog => catalog.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(dropBoxSource);
            privateObject.SetField("_lazyCat", catLog.Object);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var shape = privateObject.Invoke("FindServiceShape", Guid.NewGuid(), Guid.NewGuid()).ToString();

            //---------------Test Result -----------------------
            Assert.AreNotEqual("<DataList></DataList>", shape);
            Assert.AreEqual("SomeValue", shape);
        }