public void Unrestricted_Add() { OdbcPermission perm = new OdbcPermission(PermissionState.Unrestricted); Check("Unrestricted-NoChild", perm, false, true, 0); perm.Add("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly); // note: Lost unrestricted state when children was added Check("Unrestricted-WithChild", perm, false, false, 1); }
public void None() { OdbcPermission perm = new OdbcPermission(PermissionState.None); Check("None-1", perm, false, false, 0); perm.AllowBlankPassword = true; Check("None-2", perm, true, false, 0); OdbcPermission copy = (OdbcPermission)perm.Copy(); Check("Copy_None-1", copy, true, false, 0); copy.AllowBlankPassword = false; Check("Copy_None-2", copy, false, false, 0); }
public void Unrestricted() { OdbcPermission perm = new OdbcPermission(PermissionState.Unrestricted); Check("Unrestricted-1", perm, false, true, 0); perm.AllowBlankPassword = true; Check("Unrestricted-2", perm, true, true, 0); OdbcPermission copy = (OdbcPermission)perm.Copy(); // note: Unrestricted is always created with default values (so AllowBlankPassword is false) Check("Copy_Unrestricted-1", copy, false, true, 0); copy.AllowBlankPassword = true; Check("Copy_Unrestricted-2", copy, true, true, 0); }
public void Default() { OdbcPermissionAttribute a = new OdbcPermissionAttribute(SecurityAction.Assert); Assert.AreEqual(a.ToString(), a.TypeId.ToString(), "TypeId"); Assert.IsFalse(a.Unrestricted, "Unrestricted"); Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword"); Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString"); Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior"); Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions"); Assert.IsFalse(a.ShouldSerializeConnectionString(), "ShouldSerializeConnectionString"); Assert.IsFalse(a.ShouldSerializeKeyRestrictions(), "ShouldSerializeConnectionString"); OdbcPermission odbcp = (OdbcPermission)a.CreatePermission(); Assert.IsFalse(odbcp.IsUnrestricted(), "IsUnrestricted"); }
public void Unrestricted() { OdbcPermissionAttribute a = new OdbcPermissionAttribute(SecurityAction.Assert); a.Unrestricted = true; OdbcPermission odbcp = (OdbcPermission)a.CreatePermission(); Assert.IsTrue(odbcp.IsUnrestricted(), "IsUnrestricted"); Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword"); Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString"); Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior"); Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions"); a.Unrestricted = false; odbcp = (OdbcPermission)a.CreatePermission(); Assert.IsFalse(odbcp.IsUnrestricted(), "!IsUnrestricted"); }
public void None_Childs() { OdbcPermission perm = new OdbcPermission(PermissionState.None); perm.Add("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly); perm.Add("data source=127.0.0.1;", "password=;", KeyRestrictionBehavior.PreventUsage); Check("None-Childs-1", perm, false, false, 2); perm.AllowBlankPassword = true; Check("None-Childs-2", perm, true, false, 2); OdbcPermission copy = (OdbcPermission)perm.Copy(); Check("Copy_None-Childs-1", copy, true, false, 2); copy.AllowBlankPassword = false; Check("Copy_None-Childs-2", copy, false, false, 2); }
public void PermissionState_Invalid() { PermissionState ps = (PermissionState)Int32.MinValue; OdbcPermission perm = new OdbcPermission(ps); }