<s> """<STR_LIT>""" <EOL> import sets <EOL> from twisted . trial import unittest <EOL> from ldaptor . protocols . ldap import ldapsyntax <EOL> from ldaptor . protocols . ldap . autofill import sambaAccount , sambaSamAccount <EOL> from ldaptor import testutil <EOL> class LDAPAutoFill_sambaAccount ( unittest . TestCase ) : <EOL> def testMustHaveObjectClass ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> autoFiller = sambaAccount . Autofill_samba ( ) <EOL> d = o . addAutofiller ( autoFiller ) <EOL> def eb ( val ) : <EOL> client . assertNothingSent ( ) <EOL> val . trap ( sambaAccount . ObjectMissingObjectClassException ) <EOL> d . addCallbacks ( testutil . mustRaise , eb ) <EOL> return d <EOL> def testDefaultSetting ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaAccount . Autofill_samba ( ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testRid ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaAccount . Autofill_samba ( ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT:0>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT:0> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testPrimaryGroupId ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaAccount . Autofill_samba ( ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT:0>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT:0> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ str ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> class LDAPAutoFill_sambaSamAccount ( unittest . TestCase ) : <EOL> def testMustHaveObjectClass ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> autoFiller = sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) <EOL> d = o . addAutofiller ( autoFiller ) <EOL> def eb ( val ) : <EOL> client . assertNothingSent ( ) <EOL> val . trap ( sambaSamAccount . ObjectMissingObjectClassException ) <EOL> d . addCallbacks ( testutil . mustRaise , eb ) <EOL> return d <EOL> def testDefaultSetting ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnlessEqual ( sets . Set ( o . keys ( ) ) , sets . Set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:1>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testDefaultSetting_fixedPrimaryGroupSID ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' , <EOL> fixedPrimaryGroupSID = <NUM_LIT> ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnlessEqual ( sets . Set ( o . keys ( ) ) , sets . Set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:1>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT:0>' ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testSambaSID ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT:0>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:0> + <NUM_LIT:1000> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT:1000> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testSambaSID_preExisting ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT:1000> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testSambaPrimaryGroupSID ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT:0>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:0> + <NUM_LIT> ) ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT> + <NUM_LIT> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testSambaPrimaryGroupSID_preExisting ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' % ( <NUM_LIT:2> * <NUM_LIT:1000> + <NUM_LIT> ) ] ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testSambaPrimaryGroupSID_notUpdatedWhenFixed ( self ) : <EOL> """<STR_LIT>""" <EOL> client = testutil . LDAPClientTestDriver ( ) <EOL> o = ldapsyntax . LDAPEntryWithAutoFill ( client = client , <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) <EOL> d = o . addAutofiller ( sambaSamAccount . Autofill_samba ( domainSID = '<STR_LIT:foo>' , <EOL> fixedPrimaryGroupSID = <NUM_LIT> ) ) <EOL> def cb ( dummy ) : <EOL> client . assertNothingSent ( ) <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> o [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . failUnless ( '<STR_LIT>' in o ) <EOL> self . failUnlessEqual ( o [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> d . addCallback ( cb ) <EOL> return d </s>
