public void TestSessionGoneWhenClose() { Mock.MockCloseSessionGone restRequester = new Mock.MockCloseSessionGone(); SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester); sfSession.Open(); sfSession.close(); // no exception is raised. }
public void TestSessionRenewDuringQueryExec() { Mock.MockRestSessionExpiredInQueryExec restRequester = new Mock.MockRestSessionExpiredInQueryExec(); SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester); sfSession.Open(); SFStatement statement = new SFStatement(sfSession, restRequester); SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false); Assert.AreEqual(true, resultSet.Next()); Assert.AreEqual("1", resultSet.GetString(0)); }
public void TestSessionRenew() { Mock.MockRestSessionExpired restRequester = new Mock.MockRestSessionExpired(); SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester); sfSession.Open(); SFStatement statement = new SFStatement(sfSession, restRequester); SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false); Assert.AreEqual(true, resultSet.Next()); Assert.AreEqual("1", resultSet.GetString(0)); Assert.AreEqual("new_session_token", sfSession.sessionToken); Assert.AreEqual("new_master_token", sfSession.masterToken); }
public void TestServiceName() { var restRequester = new Mock.MockServiceName(); SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester); sfSession.Open(); string expectServiceName = Mock.MockServiceName.INIT_SERVICE_NAME; Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]); for (int i = 0; i < 5; i++) { SFStatement statement = new SFStatement(sfSession, restRequester); SFBaseResultSet resultSet = statement.Execute(0, "SELECT 1", null, false); expectServiceName += "a"; Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]); } }
public void TestSsoTokenUrlMismatch() { try { var restRequester = new Mock.MockOktaRestRequester() { TokenUrl = "https://snowflakecomputing.okta1.com/api/v1/sessions?additionalFields=cookieToken", SSOUrl = "https://snowflakecomputing.okta.com/app/snowflake_testaccountdev_1/blah/sso/saml", }; var sfSession = new SFSession("account=test;user=test;password=test;authenticator=https://snowflake.okta.com", null, restRequester); sfSession.Open(); Assert.Fail("Should not pass"); } catch (SnowflakeDbException e) { Assert.AreEqual(SFError.IDP_SSO_TOKEN_URL_MISMATCH.GetAttribute <SFErrorAttr>().errorCode, e.ErrorCode); } }
public void TestWrongPostbackUrl() { try { var restRequester = new Mock.MockOktaRestRequester() { TokenUrl = "https://snowflakecomputing.okta.com/api/v1/sessions?additionalFields=cookieToken", SSOUrl = "https://snowflakecomputing.okta.com/app/snowflake_testaccountdev_1/blah/sso/saml", ResponseContent = wrongPostbackContent, }; var sfSession = new SFSession("account=test;user=test;password=test;authenticator=https://snowflakecomputing.okta.com;host=test", null, restRequester); sfSession.Open(); Assert.Fail("Should not pass"); } catch (SnowflakeDbException e) { Assert.AreEqual(SFError.IDP_SAML_POSTBACK_INVALID.GetAttribute <SFErrorAttr>().errorCode, e.ErrorCode); } }