public void basic_authentication_with_wrong_password_exception() { var wrongCredentialsConnector = new VersionOneAPIConnector(_prefix). WithVersionOneUsernameAndPassword(_username, "foo"); using (var s = wrongCredentialsConnector.GetData(Path)) { } }
public void senddata_exercise() { var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password); connector.SendData(Path, string.Empty); }
public void windows_integrated_authentication() { var connector = new VersionOneAPIConnector(_prefix) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)) ; }
public void basic_authentication_with_constructor_supplied_credential() { var simpleCred = new NetworkCredential(_username, _password); var connector = new VersionOneAPIConnector(_prefix, simpleCred); using (connector.GetData(Path)) ; }
public void TestFixtureSetup() { _target = new FindBuilder(); string metaUrl = ConfigurationManager.AppSettings["V1Url"] + "meta.v1/"; var metaConnector = new VersionOneAPIConnector(metaUrl); _metaModel = new MetaModel(metaConnector); }
public VersionOneQuery(VersionOneSettings settings) { Settings = settings; ProxyProvider proxyProvider = ((settings.ProxySettings != null) && settings.ProxySettings.ProxyIsEnabled) ? new ProxyProvider(settings.ProxySettings.Uri, settings.ProxySettings.Username, settings.ProxySettings.Password, settings.ProxySettings.Domain) : null; processor = new VersionOneAPIConnector(settings.Path, null, proxyProvider).WithVersionOneUsernameAndPassword(settings.Username, settings.Password).WithWindowsIntegratedAuthentication(); }
public void multiple_credentials_via_user_supplied_credential_cache() { var cred = new OAuth2Client.OAuth2Credential( "apiv1", new OAuth2Client.Storage.JsonFileStorage( @"C:\Projects\github\oauth2_files\local_versiononeweb_client_secrets.json", @"C:\Projects\github\oauth2_files\local_versiononeweb_creds.json"), null ); var cache = new CredentialCache(); var simpleCred = new NetworkCredential(V1Username, V1Password); cache.Add(V1Uri, "Basic", simpleCred); cache.Add(V1Uri, "Bearer", cred); var windowsIntegratedCredential = CredentialCache.DefaultNetworkCredentials; // TODO explore: CredentialCache.DefaultCredentials // Suppose for some weird reason you just wanted to support NTLM: cache.Add(V1Uri, "NTLM", windowsIntegratedCredential); var connector = new VersionOneAPIConnector(V1Path, cache); connector.HttpGet("rest-1.v1/Data/Member/20"); }
public void getdata_parameterless_exercise() { var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password); using (var s = connector.GetData(Path)) { } }
public void senddata_exercise() { var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password); var content = "<Asset><Attribute name=\"Phone\" act=\"set\">555-555-1212</Attribute></Asset>"; using (var s = connector.SendData(Path, content)) { }; }
public void windows_integrated_authentication() { var connector = new VersionOneAPIConnector(_prefix) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)); }
public void basic_authentication_with_constructor_supplied_credential() { var simpleCred = new NetworkCredential(_username, _password); var connector = new VersionOneAPIConnector(_prefix, simpleCred); using (connector.GetData(Path)); }
public void multiple_credentials_via_user_supplied_credential_cache() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var simpleCred = new NetworkCredential(_username, _password); var windowsIntegratedCredential = CredentialCache.DefaultNetworkCredentials; var oAuth2Credential = new OAuth2Credential( "apiv1", new Storage.JsonFileStorage( secretsPath, credentialsPath), null ); var cache = new CredentialCache(); var uri = new Uri(_prefix); cache.Add(uri, "Basic", simpleCred); cache.Add(uri, "Bearer", oAuth2Credential); // Suppose for some weird reason you just wanted to support NTLM: cache.Add(uri, "NTLM", windowsIntegratedCredential); var connector = new VersionOneAPIConnector(_prefix, cache); using (connector.GetData(Path)); }
public void single_supplied_credential() { var simpleCred = new NetworkCredential(V1Username, V1Password); var connector = new VersionOneAPIConnector(V1Path, simpleCred); connector.HttpGet("rest-1.v1/Data/Member/20"); }
public void fluent_configuration_with_multiple_credentials() { var connector = new VersionOneAPIConnector(V1Path) .WithVersionOneUsernameAndPassword(V1Password, V1Username) .WithOAuth2() .WithWindowsIntegratedAuthentication(); connector.HttpGet("rest-1.v1/Data/Member/20"); }
public void fluent_configuration_with_multiple_credentials() { var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)) ; }
public void fluent_configuration_with_multiple_credentials() { var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)); }
public void basic_authentication_with_username_and_password() { // creating and configuring the connector var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password); // requesting some data that requires authentication using (connector.GetData(Path)) ; }
public void cache_same_auth_type_twice_exception() { var c1 = new NetworkCredential("user1", "pass2"); var c2 = new NetworkCredential("user2", "pass2"); var connector = new VersionOneAPIConnector(_prefix); connector.CacheCredential(c1, "Basic"); connector.CacheCredential(c2, "Basic"); }
public void basic_authentication_with_username_and_password() { // creating and configuring the connector var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password); // requesting some data that requires authentication using (connector.GetData(Path)); }
public void create_connector_with_proxy() { var uri = new Uri(Proxy); var proxyProvider = new ProxyProvider(uri, ProxyUserName, ProxyPassword); var connector = new VersionOneAPIConnector(_prefix, proxyProvider: proxyProvider) .WithVersionOneUsernameAndPassword(_username, _password); using (var s = connector.GetData(Path)) { } }
public void oauth_authentication_with_file_path_parameters() { const string secretsPath = @"C:\Temp\client_secrets.json"; const string credentialsPath = @"C:\Temp\stored_credentials.json"; var connector = new VersionOneAPIConnector(_prefix) .WithOAuth2(secretsPath, credentialsPath); connector.HttpGet(Path); }
public void oauth_authentication_with_file_parameters() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var connector = new VersionOneAPIConnector(_prefix) .WithOAuth2(secretsPath, credentialsPath); using (connector.GetData(Path)) ; }
public void oauth_authentication_with_file_parameters() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var connector = new VersionOneAPIConnector(_prefix) .WithOAuth2(secretsPath, credentialsPath); using (connector.GetData(Path)); }
public void oauth_authentication_with_storage() { var storage = new Storage.JsonFileStorage( @"ExamplesTests\client_secrets.json", @"ExamplesTests\stored_credentials.json"); var connector = new VersionOneAPIConnector(_prefix) .WithOAuth2(storage); using (connector.GetData(Path)) ; }
public void oauth_authentication_with_storage() { var storage = new Storage.JsonFileStorage( @"ExamplesTests\client_secrets.json", @"ExamplesTests\stored_credentials.json"); var connector = new VersionOneAPIConnector(_prefix) .WithOAuth2(storage); using (connector.GetData(Path)); }
public void fluent_configuration_with_multiple_credentials() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password) .WithOAuth2(secretsPath, credentialsPath) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)); }
public void TestFixtureSetup() { string username = ConfigurationManager.AppSettings["V1UserName"]; string password = ConfigurationManager.AppSettings["V1Password"]; string metaUrl = ConfigurationManager.AppSettings["V1Url"] + "meta.v1/"; string dataUrl = ConfigurationManager.AppSettings["V1Url"] + "rest-1.v1/"; var metaConnector = new VersionOneAPIConnector(metaUrl); var dataConnector = new VersionOneAPIConnector(dataUrl) .WithVersionOneUsernameAndPassword(username, password); _metaModel = new MetaModel(metaConnector); _services = new Services(_metaModel, dataConnector); }
public void multiple_credentials_via_user_supplied_credential_cache() { var simpleCred = new NetworkCredential(_username, _password); var windowsIntegratedCredential = CredentialCache.DefaultNetworkCredentials; var cache = new CredentialCache(); var uri = new Uri(_prefix); cache.Add(uri, "Basic", simpleCred); // Suppose for some weird reason you just wanted to support NTLM: cache.Add(uri, "NTLM", windowsIntegratedCredential); var connector = new VersionOneAPIConnector(_prefix, cache); using (connector.GetData(Path)) ; }
public void QueryProjects() { var proxyProvider = new ProxyProvider(new Uri(ProxyPath), ProxyUsername, ProxyPassword); IAPIConnector metaConnector = new VersionOneAPIConnector(V1Path + "meta.v1/", proxyProvider: proxyProvider) .WithVersionOneUsernameAndPassword(V1Username, V1Password); IMetaModel metaModel = new MetaModel(metaConnector); IAPIConnector dataConnector = new VersionOneAPIConnector(V1Path + "rest-1.v1/", proxyProvider: proxyProvider) .WithVersionOneUsernameAndPassword(V1Username, V1Password); IServices services = new Services(metaModel, dataConnector); var projectType = metaModel.GetAssetType("Scope"); var scopeQuery = new Query(projectType); var result = services.Retrieve(scopeQuery); Assert.IsTrue(result.Assets.Count > 0); }
public void multiple_credentials_via_user_supplied_credential_cache() { var simpleCred = new NetworkCredential(_username, _password); var windowsIntegratedCredential = CredentialCache.DefaultNetworkCredentials; var cache = new CredentialCache(); var uri = new Uri(_prefix); cache.Add(uri, "Basic", simpleCred); // Suppose for some weird reason you just wanted to support NTLM: cache.Add(uri, "NTLM", windowsIntegratedCredential); var connector = new VersionOneAPIConnector(_prefix, cache); using (connector.GetData(Path)); }
public void full_working_example_with_basic_authentication() { // Setting up a basic connection with the connector and retrieving the Member with the ID 20 var dataConnector = new VersionOneAPIConnector(_prefix + "rest-1.v1/") .WithVersionOneUsernameAndPassword(_username, _password); var metaConnector = new VersionOneAPIConnector(_prefix + "meta.v1/"); IMetaModel metaModel = new MetaModel(metaConnector); IServices services = new Services(metaModel, dataConnector); var memberId = Oid.FromToken("Member:20", metaModel); var query = new Query(memberId); var memberName = metaModel.GetAttributeDefinition("Member.Name"); query.Selection.Add(memberName); var result = services.Retrieve(query); }
static void Main(string[] args) { var dataConnector = new VersionOneAPIConnector(BASE_URL + "/rest-1.v1/").WithOAuth2(SecretsFile, CredsFile); var metaConnector = new VersionOneAPIConnector(BASE_URL + "/meta.v1/"); var metaModel = new MetaModel(metaConnector); var services = new Services(metaModel, dataConnector); var scopeType = metaModel.GetAssetType("Member"); var nameAttr = scopeType.GetAttributeDefinition("Name"); var descAttr = scopeType.GetAttributeDefinition("Nickname"); var worksItemsNameAttr = scopeType.GetAttributeDefinition("OwnedWorkitems.Name"); var query = new Query(scopeType); var whereAdmin = new FilterTerm(descAttr); whereAdmin.Equal("admin"); var whereNotTheAdmin = new FilterTerm(nameAttr); whereNotTheAdmin.NotEqual("theAdmin"); var andFilter = new AndFilterTerm(whereAdmin, whereNotTheAdmin); query.Filter = andFilter; query.Selection.AddRange(new[] { nameAttr, descAttr, worksItemsNameAttr }); var result = services.Retrieve(query); foreach (var asset in result.Assets) { Console.WriteLine("Name: " + asset.GetAttribute(nameAttr).Value); Console.WriteLine("Description: " + asset.GetAttribute(descAttr).Value); var workItems = asset.GetAttribute(worksItemsNameAttr).ValuesList; Console.WriteLine("Workitems count: " + workItems.Count); foreach (var workitem in workItems) { Console.WriteLine("Workitem: " + workitem); } } Console.ReadLine(); }
private IAPIConnector CreateConnector(string url) { // TODO check integratedAuth here var cc = new VersionOneAPIConnector(url, null, proxyProvider); if (_oauthStorage == null) { if (!_integratedAuth) { cc.WithVersionOneUsernameAndPassword(_username, _password); } else { cc.WithWindowsIntegratedAuthentication(); } } else { cc.WithOAuth2(_oauthStorage); } cc.SetUpstreamUserAgent(MyUserAgent); return(cc); }
public void no_authentication_exception() { var anonymousConnector = new VersionOneAPIConnector(_prefix); using (var s = anonymousConnector.GetData(Path)) { } }
public void cache_credential_when_init_with_credentials_exception() { var connector = new VersionOneAPIConnector(_prefix, new NetworkCredential(_username, _password)); connector.CacheCredential(new NetworkCredential(_username, _password), "Basic"); }
public void cache_credential_with_null_credentials_exception() { var connector = new VersionOneAPIConnector(_prefix); connector.CacheCredential(null, "Basic"); }
public void cache_credential_with_null_authtype_exception() { var connector = new VersionOneAPIConnector(_prefix); connector.CacheCredential(new NetworkCredential(_username, _password), null); }
public void multiple_credentials_via_user_supplied_credential_cache() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var simpleCred = new NetworkCredential(_username, _password); var windowsIntegratedCredential = CredentialCache.DefaultNetworkCredentials; var oAuth2Credential = new OAuth2Credential( "apiv1", new Storage.JsonFileStorage( secretsPath, credentialsPath), null ); var cache = new CredentialCache(); var uri = new Uri(_prefix); cache.Add(uri, "Basic", simpleCred); cache.Add(uri, "Bearer", oAuth2Credential); // Suppose for some weird reason you just wanted to support NTLM: cache.Add(uri, "NTLM", windowsIntegratedCredential); var connector = new VersionOneAPIConnector(_prefix, cache); using (connector.GetData(Path)) ; }
public void fluent_configuration_with_multiple_credentials() { const string secretsPath = @"ExamplesTests\client_secrets.json"; const string credentialsPath = @"ExamplesTests\stored_credentials.json"; var connector = new VersionOneAPIConnector(_prefix) .WithVersionOneUsernameAndPassword(_username, _password) .WithOAuth2(secretsPath, credentialsPath) .WithWindowsIntegratedAuthentication(); using (connector.GetData(Path)) ; }