Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SNOW-1881731] Add externalBrowser, oauth, okta, keypair automated authentication tests #1082

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-pcyrek
Copy link

@sfc-gh-pcyrek sfc-gh-pcyrek commented Jan 23, 2025

Description

Please explain the changes you made here.

This PR adds automated tests for externalBrowser, oauth, okta, keypair authentication methods

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

return properties;
}

public static String SetBaseConnectionParameters(Dictionary<string, string> param)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. return string not String
  2. params - plural form is better
  3. the name of method is not describing what this method is dooing. Maybe GetBaseConnectionString could be better?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Ok
  2. 'params' is restricted word, I will use 'parameters'
  3. I will keep GET/SET convention but change ConnectionParameters to 'ConnectionString'

var parameters = AuthConnectionParameters.GetExternalBrowserConnectionParameters();

parameters["user"] = "differentUser";
_connectionString = AuthConnectionParameters.SetExternalBrowserConnectionParameters(parameters);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we use shared _connectionString field?
I we would create connectionString variable in each test, the tests would be independent from each other

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connection string each time is setup to the default value, furthermore it use static methods to be setup

{
var parameters = AuthConnectionParameters.GetExternalBrowserConnectionParameters();

_connectionString = AuthConnectionParameters.SetExternalBrowserConnectionParameters(parameters);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if AuthConnectionParameters.GetExternalBrowserConnectionParameters() method could take BROWSER_RESPONSE_TIMEOUT as a parameter
and if we used instead of SetExternalBrowserConnectionParameters, a dedicated to external browser a generic method which transforms a dictionary into a connectin string then all the methods Set... would be not needed and such things neither _connectionString += "BROWSER_RESPONSE_TIMEOUT=1;";

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea behind helper is to initialise integration with minimal number of parameters and to make them common for each kind of integration, it was made that way for each driver.

namespace Snowflake.Data.Tests.AuthenticationTests
{
[NonParallelizable]
public class KeyPairConnection : SFBaseTest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyPairConnectionTest ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

namespace Snowflake.Data.Tests.AuthenticationTests
{
[NonParallelizable]
public class OauthConnection : SFBaseTest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OAuthConnectionTest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

namespace Snowflake.Data.Tests.AuthenticationTests
{
[NonParallelizable]
public class OktaConnection : SFBaseTest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OktaConnectionTest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.13%. Comparing base (cab672d) to head (ad5dcac).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1082      +/-   ##
==========================================
- Coverage   86.20%   86.13%   -0.08%     
==========================================
  Files         131      131              
  Lines       12554    12554              
  Branches     1290     1290              
==========================================
- Hits        10822    10813       -9     
- Misses       1414     1423       +9     
  Partials      318      318              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfc-gh-pcyrek sfc-gh-pcyrek marked this pull request as ready for review January 29, 2025 13:10
@sfc-gh-pcyrek sfc-gh-pcyrek requested a review from a team as a code owner January 29, 2025 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants