public bool GetOAuthResponse(bool includeCompleteUri, string key1, string key2, Type expectedType) { //Arrange var oauth2AuthHelper = new OAuth2AuthenticationHelper(GetOAuthCompleteUri()); var list = GetNavigationUris(); var dictionary = new Dictionary <string, string>(); dictionary.Add(key1, key1 + 123); dictionary.Add(key2, key2 + 123); if (includeCompleteUri) { list.Add(GetOAuthCompleteUriWithParameters(dictionary)); } //Act bool found = false; IOAuthResponse response = null; foreach (var uri in list) { if (oauth2AuthHelper.IsComplete(uri, out response)) { found = true; break; } } return(found && (response != null && response.GetType() == expectedType)); }
public void OAuthResponseBase_PropertiesMapped() { //Arrange var oauth2AuthHelper = new OAuth2AuthenticationHelper(GetOAuthCompleteUri()); var list = GetNavigationUris(1); var dictionary = new Dictionary <string, string>(); dictionary.Add("appcp", "sharefile.com"); dictionary.Add("apicp", "sf-api.com"); dictionary.Add("randomKey", "randomValue"); list.Add(GetOAuthCompleteUriWithParameters(dictionary)); //Act bool found = false; IOAuthResponse response = null; foreach (var uri in list) { if (oauth2AuthHelper.IsComplete(uri, out response)) { found = true; break; } } response.GetType().Should().Be(typeof(OAuthResponseBase)); response.Properties.Should().NotBeNull(); var oauthResponseBase = response as OAuthResponseBase; oauthResponseBase.ApiControlPlane.Should().Be("sf-api.com"); oauthResponseBase.ApplicationControlPlane.Should().Be("sharefile.com"); oauthResponseBase.Properties.Should().ContainKey("randomKey"); }
public ShareFileWebAuthentication() { InitializeComponent(); _sfClient = new ShareFileClient("https://secure.sf-api.com/sf/v3/"); _oauthService = new OAuthService(_sfClient, _oauthClientId, _oauthClientSecret); _authenticationHelper = new OAuth2AuthenticationHelper(_completionUri); }