/// <summary> /// Check a user password. Useful if you have specific privileged actions /// requiring users to confirm their password. /// </summary> /// <param name="userIdOrEmail">user id or email address</param> /// <param name="password">user password</param> /// <returns></returns> public Boolean CheckPassword(string userIdOrEmail, string password) { var rgx = new Regex(@".*@.*\.(\w+)"); var att = new NameValueCollection(); att.Add("password", MnoEncryptor.encrypt(password, MnoHelper.With(presetName).Api.Key)); // Check if we should match the password against the id or email if (rgx.IsMatch(userIdOrEmail)) { att.Add("email", userIdOrEmail); } else { att.Add("id", userIdOrEmail); } try { // Raise an error on failure MnoClient.Create <User>(User.IndexPath() + "/authenticate", att, presetName); return(true); } catch (Maestrano.Api.ResourceException) { return(false); } }
/// <summary> /// Return wether the session is valid or not. Perform /// remote check to maestrano if recheck is overdue. /// </summary> /// <param name="client"></param> /// <param name="ifSession"></param> /// <returns></returns> public Boolean IsValid(RestClient client, Boolean ifSession = false) { // Return true automatically if SLO is disabled if (!MnoHelper.With(presetName).Sso.SloEnabled) { return(true); } // Return true if maestrano session not set // and ifSession option enabled if (ifSession && (HttpSession == null || HttpSession[presetName] == null)) { return(true); } // Return false if HttpSession is nil if (HttpSession == null) { return(false); } if (isRemoteCheckRequired()) { if (PerformRemoteCheck(client)) { Save(); return(true); } else { return(false); } } return(true); }
public void MaskUser_WhenVirtualMode_ItReturnsTheRightValues() { MnoHelper.Environment = "production"; MnoHelper.Sso.CreationMode = "virtual"; Assert.AreEqual("usr-1.cld-1", MnoHelper.MaskUser("usr-1", "cld-1")); }
private RestClient InternalClient() { if (_client == null) { var connecBasePath = MnoHelper.With(presetName).Connec.BasePath; var connecScopedPath = connecBasePath + "/" + groupId; // silverlight friendly way to get current version var assembly = Assembly.GetExecutingAssembly(); AssemblyName assemblyName = new AssemblyName(assembly.FullName); var version = assemblyName.Version; _client = new RestClient(); _client.UserAgent = "maestrano-dotnet/" + version; _client.AddDefaultHeader("Accept", "application/vnd.api+json"); _client.AddDefaultHeader("Content-Type", "application/vnd.api+json"); _client.Authenticator = new HttpBasicAuthenticator( MnoHelper.With(presetName).Api.Id, MnoHelper.With(presetName).Api.Key ); _client.BaseUrl = String.Format("{0}{1}", MnoHelper.With(presetName).Connec.Host, connecScopedPath ); } return(_client); }
public void Sso_ItBuildsTheRightSamlRequest() { MnoHelper.With("sometenant").Environment = "production"; var ssoIdpUrl = MnoHelper.With("sometenant").Sso.BuildRequest(null).RedirectUrl(); Assert.IsTrue(ssoIdpUrl.StartsWith("https://idp.sometenant.com")); }
public void itSetsTheDefaultIdpHostProperly() { MnoHelper.ClearPreset("someothertenant"); MnoHelper.Environment = "production"; MnoHelper.With("someothertenant").Environment = "development"; Assert.AreEqual("http://api-sandbox.maestrano.io", MnoHelper.With("someothertenant").Sso.Idp); }
public void itSetsTheApiTokenProperly() { MnoHelper.With("sometenant").Environment = "production"; MnoHelper.With("sometenant").Api.Id = "app-1"; MnoHelper.With("sometenant").Api.Key = "bla"; Assert.AreEqual("app-1:bla", MnoHelper.With("sometenant").Api.Token); }
public void itGeneratesTheMetadataWithoutError() { MnoHelper.With("sometenant").Environment = "production"; MnoHelper.With("sometenant").Api.Id = "app-1"; MnoHelper.With("sometenant").Api.Key = "bla"; Assert.IsNotNull(MnoHelper.With("sometenant").ToMetadata()); }
public void AutoConfigure_withParameters() { var host = "https://developer-uat.maestrano.io"; var path = "/api/config/v1"; var key = "08440d6f-a16c-4f89-87d3-603113a1d099"; var secret = "xAzIal70cmiR4Y_dkQZF-A"; MnoHelper.AutoConfigure(host, path, key, secret); }
public void AutoConfigure_invalidCredential_throwsAnAutoConfigureException() { var host = "https://dev-platform.maestrano.io"; var path = "/api/config/v1"; var key = "INVALID"; var secret = "INVALID"; MnoHelper.AutoConfigure(host, path, key, secret); }
public void AutoConfigure_withParameters() { var host = "https://dev-platform.maestrano.io"; var path = "/api/config/v1"; var key = "5c8183d9-f76f-4ada-bb25-9e4643h4a70e"; var secret = "LS7rHne2pDTZY0YBNq6pxg"; MnoHelper.AutoConfigure(host, path, key, secret); }
public void RegisterMarketplace_ItRegisterFromFile() { var byteArray = Properties.Resources.developerPlatformAnswer; var content = System.Text.Encoding.UTF8.GetString(byteArray); var preset = MnoHelper.RegisterMarketplaceFromJson(content); Assert.AreEqual("http://localhost:63705", preset.App.Host); }
public void itSetsTheX509CertificateProperly() { MnoHelper.ClearPreset("sometenant"); MnoHelper.Environment = "production"; MnoHelper.With("sometenant").Environment = "development"; Assert.AreEqual("01:06:15:89:25:7d:78:12:28:a6:69:c7:de:63:ed:74:21:f9:f5:36", MnoHelper.With("sometenant").Sso.X509Fingerprint); Assert.AreEqual("-----BEGIN CERTIFICATE-----\nMIIDezCCAuSgAwIBAgIJAOehBr+YIrhjMA0GCSqGSIb3DQEBBQUAMIGGMQswCQYD\nVQQGEwJBVTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxGjAYBgNVBAoT\nEU1hZXN0cmFubyBQdHkgTHRkMRYwFAYDVQQDEw1tYWVzdHJhbm8uY29tMSQwIgYJ\nKoZIhvcNAQkBFhVzdXBwb3J0QG1hZXN0cmFuby5jb20wHhcNMTQwMTA0MDUyMjM5\nWhcNMzMxMjMwMDUyMjM5WjCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEP\nMA0GA1UEBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQG\nA1UEAxMNbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVz\ndHJhbm8uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVkIqo5t5Paflu\nP2zbSbzxn29n6HxKnTcsubycLBEs0jkTkdG7seF1LPqnXl8jFM9NGPiBFkiaR15I\n5w482IW6mC7s8T2CbZEL3qqQEAzztEPnxQg0twswyIZWNyuHYzf9fw0AnohBhGu2\n28EZWaezzT2F333FOVGSsTn1+u6tFwIDAQABo4HuMIHrMB0GA1UdDgQWBBSvrNxo\neHDm9nhKnkdpe0lZjYD1GzCBuwYDVR0jBIGzMIGwgBSvrNxoeHDm9nhKnkdpe0lZ\njYD1G6GBjKSBiTCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEPMA0GA1UE\nBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQGA1UEAxMN\nbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVzdHJhbm8u\nY29tggkA56EGv5giuGMwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCc\nMPgV0CpumKRMulOeZwdpnyLQI/NTr3VVHhDDxxCzcB0zlZ2xyDACGnIG2cQJJxfc\n2GcsFnb0BMw48K6TEhAaV92Q7bt1/TYRvprvhxUNMX2N8PHaYELFG2nWfQ4vqxES\nRkjkjqy+H7vir/MOF3rlFjiv5twAbDKYHXDT7v1YCg==\n-----END CERTIFICATE-----", MnoHelper.With("sometenant").Sso.X509Certificate); }
public void Authenticate_ItReturnsTheRightValues() { MnoHelper.Environment = "production"; MnoHelper.Api.Id = "app-1"; MnoHelper.Api.Key = "somekey"; Assert.AreEqual(true, MnoHelper.Authenticate(MnoHelper.Api.Id, MnoHelper.Api.Key)); Assert.AreEqual(false, MnoHelper.Authenticate(MnoHelper.Api.Id, "someotherrandomkey")); }
public Settings SamlSettings() { if (settings == null) { settings = MnoHelper.With(presetName).Sso.SamlSettings(); } return(settings); }
/// <summary> /// Return the Certificate used by the Response object /// </summary> /// <returns></returns> public Certificate SamlCertificate() { if (certificate == null) { certificate = new Certificate(); certificate.LoadCertificate(MnoHelper.With(presetName).Sso.SamlSettings().IdpCertificate); } return(certificate); }
public void itSetsTheHostAndIdmProperlyIfDefined() { MnoHelper.ClearPreset("sometenant"); MnoHelper.With("sometenant").Environment = "production"; string expected = "https://somerandomhost.com"; MnoHelper.With("sometenant").App.Host = expected; MnoHelper.With("sometenant").Sso.Idm = expected; }
/// <summary> /// Return the real Email if Maestrano.Sso.CreationMode is set /// to "real" and the VirtualEmail otherwise ("virtual" mode) /// </summary> public string ToEmail() { if (MnoHelper.With(presetName).Sso.CreationMode.Equals("real")) { return(Email); } else { return(VirtualEmail); } }
public void isDevelopment_ItReturnsTheRightValues() { MnoHelper.Environment = "production"; Assert.IsFalse(MnoHelper.isDevelopment()); MnoHelper.Environment = "production-sandbox"; Assert.IsFalse(MnoHelper.isDevelopment()); MnoHelper.Environment = "development"; Assert.IsTrue(MnoHelper.isDevelopment()); MnoHelper.Environment = "test"; Assert.IsTrue(MnoHelper.isDevelopment()); }
/// <summary> /// Return the SAML Settings to be used by the SAML Request /// and Response classes /// </summary> /// <returns></returns> public Saml.Settings SamlSettings() { Saml.Settings settings = new Saml.Settings(); settings.AssertionConsumerServiceUrl = ConsumeUrl(); settings.IdpSsoTargetUrl = IdpUrl(); settings.IdpCertificate = X509Certificate; settings.Issuer = MnoHelper.With(presetName).Api.Id; settings.NameIdentifierFormat = NameIdFormat; return(settings); }
public void itSetsTheHostAndIdmProperlyIfDefined() { MnoHelper.ClearPreset("maestrano"); MnoHelper.Environment = "production"; string expected = "https://mysuperapp.com"; MnoHelper.App.Host = expected; Assert.AreEqual(expected, MnoHelper.App.Host); Assert.AreEqual(expected, MnoHelper.Sso.Idm); }
public void itSetsTheHostAndIdmProperlyIfDefined() { MnoHelper.With("sometenant").Environment = "production"; string expected = "https://somerandomhost.com"; MnoHelper.With("sometenant").App.Host = expected; MnoHelper.With("sometenant").Sso.Idm = expected; Assert.AreEqual(expected, MnoHelper.With("sometenant").App.Host); Assert.AreEqual(expected, MnoHelper.With("sometenant").Sso.Idm); }
public void Sso_ItBuildsTheRightSamlSettings() { MnoHelper.With("sometenant").Environment = "production"; MnoHelper.With("sometenant").Api.Id = "app-tenant1"; MnoHelper.With("sometenant").Sso.Idp = "https://idp.sometenantspecificendpoint.com"; MnoHelper.With("sometenant").Sso.Idm = "https://somespecificapphost.com"; MnoHelper.With("sometenant").Sso.ConsumePath = "/somespecifictenant/auth/saml/consume"; var samlSettings = MnoHelper.With("sometenant").Sso.SamlSettings(); Assert.AreEqual("app-tenant1", samlSettings.Issuer); Assert.AreEqual("https://idp.sometenantspecificendpoint.com/api/v1/auth/saml", samlSettings.IdpSsoTargetUrl); Assert.AreEqual("https://somespecificapphost.com/somespecifictenant/auth/saml/consume", samlSettings.AssertionConsumerServiceUrl); }
private static JsonClient Client(string presetName = "maestrano") { if (!clientDict.ContainsKey(presetName)) { var preset = MnoHelper.With(presetName); string host = preset.Api.Host; string path = preset.Api.Base; string key = preset.Api.Id; string secret = preset.Api.Key; var client = new JsonClient(host, path, key, secret); clientDict.Add(presetName, client); } return(clientDict[presetName]); }
/// <summary> /// Return a Client for a specific preset /// New scoped clients can be initialized with: Client.New("group-id", "preset") /// </summary> /// <param name="presetName"></param> /// <returns></returns> public static Client New(string groupId, string presetName = "maestrano") { if (presetName == null) { presetName = "maestrano"; } var preset = MnoHelper.With(presetName); var host = preset.Connec.Host; var path = preset.Connec.BasePath; var apiId = preset.Api.Id; var apiKey = preset.Api.Key; var connecScopedPath = path + "/" + groupId; return(new Client(host, connecScopedPath, apiId, apiKey)); }
public void ToMetadata_ItReturnsTheRightObject() { MnoHelper.Environment = "production"; MnoHelper.App.Host = "https://mysuperapp.com"; MnoHelper.Api.Id = "app-1"; MnoHelper.Api.Key = "somekey"; JObject expected = new JObject( new JProperty("environment", MnoHelper.Environment), new JProperty("app", new JObject(new JProperty("host", MnoHelper.App.Host))), new JProperty("api", new JObject( new JProperty("id", MnoHelper.Api.Id), new JProperty("lang", MnoHelper.Api.Lang), new JProperty("version", MnoHelper.Api.Version), new JProperty("lang_version", MnoHelper.Api.LangVersion))), new JProperty("sso", new JObject( new JProperty("enabled", MnoHelper.Sso.Enabled), new JProperty("creation_mode", MnoHelper.Sso.CreationMode), new JProperty("init_path", MnoHelper.Sso.InitPath), new JProperty("consume_path", MnoHelper.Sso.ConsumePath), new JProperty("idm", MnoHelper.Sso.Idm), new JProperty("idp", MnoHelper.Sso.Idp), new JProperty("name_id_format", MnoHelper.Sso.NameIdFormat), new JProperty("x509_fingerprint", MnoHelper.Sso.X509Fingerprint), new JProperty("x509_certificate", MnoHelper.Sso.X509Certificate))), new JProperty("webhook", new JObject( new JProperty("account", new JObject( new JProperty("groups_path", MnoHelper.Webhook.Account.GroupsPath), new JProperty("group_users_path", MnoHelper.Webhook.Account.GroupUsersPath) )), new JProperty("connec", new JObject( new JProperty("notifications_path", MnoHelper.Webhook.Connec.NotificationsPath), new JProperty("subscriptions", new JObject( new JProperty("accounts", MnoHelper.Webhook.Connec.Subscriptions.Accounts), new JProperty("company", MnoHelper.Webhook.Connec.Subscriptions.Company), new JProperty("invoices", MnoHelper.Webhook.Connec.Subscriptions.Invoices), new JProperty("items", MnoHelper.Webhook.Connec.Subscriptions.Items), new JProperty("organizations", MnoHelper.Webhook.Connec.Subscriptions.Organizations), new JProperty("payments", MnoHelper.Webhook.Connec.Subscriptions.Payments), new JProperty("people", MnoHelper.Webhook.Connec.Subscriptions.People), new JProperty("tax_codes", MnoHelper.Webhook.Connec.Subscriptions.TaxCodes), new JProperty("tax_rates", MnoHelper.Webhook.Connec.Subscriptions.TaxRates) )) )))) ); Assert.AreEqual(expected.ToString(), MnoHelper.ToMetadata().ToString()); }
public void itHasTheRightDefaultTestConfig() { MnoHelper.ClearPreset("sometenant"); MnoHelper.Environment = "development"; // App Assert.AreEqual("http://myapp.com", MnoHelper.With("sometenant").App.Host); // API Assert.AreEqual("http://api-sandbox.maestrano.io", MnoHelper.With("sometenant").Api.Host); Assert.AreEqual("/api/v1/", MnoHelper.With("sometenant").Api.Base); Assert.AreEqual("C#", MnoHelper.With("sometenant").Api.Lang); Assert.AreEqual(MnoHelper.Version, MnoHelper.With("sometenant").Api.Version); Assert.AreEqual(Environment.OSVersion.ToString() + " - " + Environment.Version.ToString(), MnoHelper.With("sometenant").Api.LangVersion); // SSO Assert.IsTrue(MnoHelper.With("sometenant").Sso.Enabled); Assert.IsTrue(MnoHelper.With("sometenant").Sso.SloEnabled); Assert.AreEqual("https://idp.sometenant.com", MnoHelper.With("sometenant").Sso.Idp); Assert.AreEqual("https://idm.myapp.com", MnoHelper.With("sometenant").Sso.Idm); Assert.AreEqual("virtual", MnoHelper.With("sometenant").Sso.CreationMode); Assert.AreEqual("/sometenant/auth/saml/init.aspx", MnoHelper.With("sometenant").Sso.InitPath); Assert.AreEqual("/sometenant/auth/saml/consume", MnoHelper.With("sometenant").Sso.ConsumePath); Assert.AreEqual("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", MnoHelper.With("sometenant").Sso.NameIdFormat); Assert.AreEqual("01:06:15:89:25:7d:78:12:28:a6:69:c7:de:63:ed:74:21:f9:f5:36", MnoHelper.With("sometenant").Sso.X509Fingerprint); Assert.AreEqual("-----BEGIN CERTIFICATE-----\nMIIDezCCAuSgAwIBAgIJAOehBr+YIrhjMA0GCSqGSIb3DQEBBQUAMIGGMQswCQYD\nVQQGEwJBVTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxGjAYBgNVBAoT\nEU1hZXN0cmFubyBQdHkgTHRkMRYwFAYDVQQDEw1tYWVzdHJhbm8uY29tMSQwIgYJ\nKoZIhvcNAQkBFhVzdXBwb3J0QG1hZXN0cmFuby5jb20wHhcNMTQwMTA0MDUyMjM5\nWhcNMzMxMjMwMDUyMjM5WjCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEP\nMA0GA1UEBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQG\nA1UEAxMNbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVz\ndHJhbm8uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVkIqo5t5Paflu\nP2zbSbzxn29n6HxKnTcsubycLBEs0jkTkdG7seF1LPqnXl8jFM9NGPiBFkiaR15I\n5w482IW6mC7s8T2CbZEL3qqQEAzztEPnxQg0twswyIZWNyuHYzf9fw0AnohBhGu2\n28EZWaezzT2F333FOVGSsTn1+u6tFwIDAQABo4HuMIHrMB0GA1UdDgQWBBSvrNxo\neHDm9nhKnkdpe0lZjYD1GzCBuwYDVR0jBIGzMIGwgBSvrNxoeHDm9nhKnkdpe0lZ\njYD1G6GBjKSBiTCBhjELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEPMA0GA1UE\nBxMGU3lkbmV5MRowGAYDVQQKExFNYWVzdHJhbm8gUHR5IEx0ZDEWMBQGA1UEAxMN\nbWFlc3RyYW5vLmNvbTEkMCIGCSqGSIb3DQEJARYVc3VwcG9ydEBtYWVzdHJhbm8u\nY29tggkA56EGv5giuGMwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCc\nMPgV0CpumKRMulOeZwdpnyLQI/NTr3VVHhDDxxCzcB0zlZ2xyDACGnIG2cQJJxfc\n2GcsFnb0BMw48K6TEhAaV92Q7bt1/TYRvprvhxUNMX2N8PHaYELFG2nWfQ4vqxES\nRkjkjqy+H7vir/MOF3rlFjiv5twAbDKYHXDT7v1YCg==\n-----END CERTIFICATE-----", MnoHelper.With("sometenant").Sso.X509Certificate); // Connec Assert.AreEqual("http://api-sandbox.maestrano.io", MnoHelper.With("sometenant").Connec.Host); Assert.AreEqual("/connec/api/v2", MnoHelper.With("sometenant").Connec.BasePath); // Webhook Assert.AreEqual("/maestrano/account/groups/:id", MnoHelper.With("sometenant").Webhook.Account.GroupsPath); Assert.AreEqual("/maestrano/account/groups/:group_id/users/:id", MnoHelper.With("sometenant").Webhook.Account.GroupUsersPath); Assert.AreEqual("/maestrano/connec/notifications", MnoHelper.With("sometenant").Webhook.Connec.NotificationsPath); // Webhook - Connec! Subscriptions Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Accounts); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Company); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Invoices); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Items); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Organizations); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Payments); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.People); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.TaxCodes); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.TaxRates); }
public void itHasTheRightDefaultTestConfig() { MnoHelper.ClearPreset("sometenant"); MnoHelper.With("sometenant").Environment = "development"; // App Assert.AreEqual("http://myapp.com", MnoHelper.With("sometenant").App.Host); // API Assert.AreEqual("http://api-sandbox.maestrano.io", MnoHelper.With("sometenant").Api.Host); Assert.AreEqual("/api/v1/", MnoHelper.With("sometenant").Api.Base); Assert.AreEqual("C#", MnoHelper.With("sometenant").Api.Lang); Assert.AreEqual(MnoHelper.Version, MnoHelper.With("sometenant").Api.Version); Assert.AreEqual(Environment.OSVersion.ToString() + " - " + Environment.Version.ToString(), MnoHelper.With("sometenant").Api.LangVersion); // SSO Assert.IsTrue(MnoHelper.With("sometenant").Sso.Enabled); Assert.IsTrue(MnoHelper.With("sometenant").Sso.SloEnabled); Assert.AreEqual("https://idp.sometenant.com", MnoHelper.With("sometenant").Sso.Idp); Assert.AreEqual("https://idm.myapp.com", MnoHelper.With("sometenant").Sso.Idm); Assert.AreEqual("virtual", MnoHelper.With("sometenant").Sso.CreationMode); Assert.AreEqual("/sometenant/auth/saml/init.aspx", MnoHelper.With("sometenant").Sso.InitPath); Assert.AreEqual("/sometenant/auth/saml/consume", MnoHelper.With("sometenant").Sso.ConsumePath); Assert.AreEqual("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", MnoHelper.With("sometenant").Sso.NameIdFormat); // Connec Assert.AreEqual("http://api-sandbox.maestrano.io", MnoHelper.With("sometenant").Connec.Host); Assert.AreEqual("/connec/api/v2", MnoHelper.With("sometenant").Connec.BasePath); // Webhook Assert.AreEqual("/maestrano/account/groups/:id", MnoHelper.With("sometenant").Webhook.Account.GroupsPath); Assert.AreEqual("/maestrano/account/groups/:group_id/users/:id", MnoHelper.With("sometenant").Webhook.Account.GroupUsersPath); Assert.AreEqual("/maestrano/connec/notifications", MnoHelper.With("sometenant").Webhook.Connec.NotificationsPath); // Webhook - Connec! Subscriptions Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Accounts); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Company); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Invoices); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Items); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Organizations); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.Payments); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.People); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.TaxCodes); Assert.IsFalse(MnoHelper.With("sometenant").Webhook.Connec.Subscriptions.TaxRates); }
private static RestClient Client(string presetName = "maestrano") { if (!clientDict.ContainsKey(presetName)) { var client = new RestClient(); // silverlight friendly way to get current version var assembly = Assembly.GetExecutingAssembly(); AssemblyName assemblyName = new AssemblyName(assembly.FullName); var version = assemblyName.Version; client = new RestClient(); client.UserAgent = "maestrano-dotnet/" + version; client.Authenticator = new HttpBasicAuthenticator(MnoHelper.With(presetName).Api.Id, MnoHelper.With(presetName).Api.Key); client.BaseUrl = String.Format("{0}{1}", MnoHelper.With(presetName).Api.Host, MnoHelper.With(presetName).Api.Base); clientDict.Add(presetName, client); } return(clientDict[presetName]); }
public void ToMetadata_ItReturnsTheRightObject() { MnoHelper.Environment = "production"; MnoHelper.App.Host = "https://mysuperapp.com"; MnoHelper.Api.Id = "app-1"; MnoHelper.Api.Key = "somekey"; JObject expected = new JObject( new JProperty("environment", MnoHelper.Environment), new JProperty("app", new JObject(new JProperty("host", MnoHelper.App.Host))), new JProperty("api", new JObject( new JProperty("id", MnoHelper.Api.Id), new JProperty("lang", MnoHelper.Api.Lang), new JProperty("version", MnoHelper.Api.Version), new JProperty("lang_version", MnoHelper.Api.LangVersion))), new JProperty("sso", new JObject( new JProperty("enabled", MnoHelper.Sso.Enabled), new JProperty("creation_mode", MnoHelper.Sso.CreationMode), new JProperty("init_path", MnoHelper.Sso.InitPath), new JProperty("consume_path", MnoHelper.Sso.ConsumePath), new JProperty("idm", MnoHelper.Sso.Idm), new JProperty("idp", MnoHelper.Sso.Idp), new JProperty("name_id_format", MnoHelper.Sso.NameIdFormat), new JProperty("x509_fingerprint", MnoHelper.Sso.X509Fingerprint), new JProperty("x509_certificate", MnoHelper.Sso.X509Certificate))), new JProperty("webhook", new JObject( new JProperty("account", new JObject( new JProperty("groups_path", MnoHelper.Webhook.Account.GroupsPath), new JProperty("group_users_path", MnoHelper.Webhook.Account.GroupUsersPath) )), new JProperty("connec", new JObject( new JProperty("notifications_path", MnoHelper.Webhook.Connec.NotificationsPath), new JProperty("subscriptions", new JObject( new JProperty("accounts", MnoHelper.Webhook.Connec.Subscriptions.Accounts), new JProperty("company", MnoHelper.Webhook.Connec.Subscriptions.Company), new JProperty("invoices", MnoHelper.Webhook.Connec.Subscriptions.Invoices), new JProperty("sales_orders", MnoHelper.Webhook.Connec.Subscriptions.SalesOrders), new JProperty("purchase_orders", MnoHelper.Webhook.Connec.Subscriptions.PurchaseOrders), new JProperty("quotes", MnoHelper.Webhook.Connec.Subscriptions.Quotes), new JProperty("payments", MnoHelper.Webhook.Connec.Subscriptions.Payments), new JProperty("journals", MnoHelper.Webhook.Connec.Subscriptions.Journals), new JProperty("items", MnoHelper.Webhook.Connec.Subscriptions.Items), new JProperty("organizations", MnoHelper.Webhook.Connec.Subscriptions.Organizations), new JProperty("people", MnoHelper.Webhook.Connec.Subscriptions.People), new JProperty("projects", MnoHelper.Webhook.Connec.Subscriptions.Projects), new JProperty("tax_codes", MnoHelper.Webhook.Connec.Subscriptions.TaxCodes), new JProperty("tax_rates", MnoHelper.Webhook.Connec.Subscriptions.TaxRates), new JProperty("events", MnoHelper.Webhook.Connec.Subscriptions.Events), new JProperty("venues", MnoHelper.Webhook.Connec.Subscriptions.Venues), new JProperty("event_orders", MnoHelper.Webhook.Connec.Subscriptions.EventOrders), new JProperty("work_locations", MnoHelper.Webhook.Connec.Subscriptions.WorkLocations), new JProperty("pay_items", MnoHelper.Webhook.Connec.Subscriptions.PayItems), new JProperty("employees", MnoHelper.Webhook.Connec.Subscriptions.Employees), new JProperty("pay_schedules", MnoHelper.Webhook.Connec.Subscriptions.PaySchedules), new JProperty("time_sheets", MnoHelper.Webhook.Connec.Subscriptions.TimeSheets), new JProperty("time_activities", MnoHelper.Webhook.Connec.Subscriptions.TimeActivities), new JProperty("pay_runs", MnoHelper.Webhook.Connec.Subscriptions.PayRuns), new JProperty("pay_stubs", MnoHelper.Webhook.Connec.Subscriptions.PayStubs) )) )))) ); Assert.AreEqual(expected.ToString(), MnoHelper.ToMetadata().ToString()); }