コード例 #1
0
    def testDefaultSetting_fixedPrimaryGroupSID(self):
        """Test that fields get their default values."""
        client = testutil.LDAPClientTestDriver()
        o=ldapsyntax.LDAPEntryWithAutoFill(client=client,
                                           dn='cn=foo,dc=example,dc=com',
                                           attributes={
            'objectClass': ['sambaSamAccount', 'other'],
            })
        d = o.addAutofiller(sambaSamAccount.Autofill_samba(domainSID='foo',
                                                           fixedPrimaryGroupSID=4131312))
        def cb(dummy):
            client.assertNothingSent()

            self.failUnlessEqual(sets.Set(o.keys()), sets.Set([
                'objectClass',
                'sambaAcctFlags',
                'sambaLogoffTime',
                'sambaLogonTime',
                'sambaPwdCanChange',
                'sambaPwdLastSet',
                'sambaPwdMustChange',
                'sambaPrimaryGroupSID',
                ]))

            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-4131312'])
            self.failUnlessEqual(o['sambaAcctFlags'], ['[UX         ]'])
            self.failUnlessEqual(o['sambaPwdLastSet'], ['0'])
            self.failUnlessEqual(o['sambaLogonTime'], ['0'])
            self.failUnlessEqual(o['sambaLogoffTime'], ['0'])
            self.failUnlessEqual(o['sambaPwdCanChange'], ['0'])
            self.failUnlessEqual(o['sambaPwdMustChange'], ['0'])
        d.addCallback(cb)
        return d
コード例 #2
0
    def testSambaPrimaryGroupSID(self):
        """Test that sambaPrimaryGroupSID field is updated based on gidNumber."""
        client = testutil.LDAPClientTestDriver()
        o=ldapsyntax.LDAPEntryWithAutoFill(client=client,
                                            dn='cn=foo,dc=example,dc=com',
                                            attributes={
            'objectClass': ['sambaSamAccount', 'other'],
            })
        d = o.addAutofiller(sambaSamAccount.Autofill_samba(domainSID='foo'))
        def cb(dummy):
            client.assertNothingSent()

            o['gidNumber'] = ['1000']
            self.failUnless('sambaPrimaryGroupSID' in o)
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*1000+1001)])
            o['gidNumber'] = ['1001']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*1001+1001)])
            o['gidNumber'] = ['1002']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*1002+1001)])
            o['gidNumber'] = ['2000']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*2000+1001)])
            o['gidNumber'] = ['3000']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*3000+1001)])
            o['gidNumber'] = ['0']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*0+1001)])
            o['gidNumber'] = ['16000']
            self.failUnlessEqual(o['sambaPrimaryGroupSID'], ['foo-%s' % (2*16000+1001)])
        d.addCallback(cb)
        return d
コード例 #3
0
    def testMustHaveObjectClass(self):
        """Test that Autofill_samba fails unless object is a sambaSamAccount."""
        client = testutil.LDAPClientTestDriver()
        o=ldapsyntax.LDAPEntryWithAutoFill(client=client,
                                           dn='cn=foo,dc=example,dc=com',
                                           attributes={
            'objectClass': ['something', 'other'],
            })
        autoFiller = sambaSamAccount.Autofill_samba(domainSID='foo')
        d = o.addAutofiller(autoFiller)

        def eb(val):
            client.assertNothingSent()
            val.trap(sambaSamAccount.ObjectMissingObjectClassException)
        d.addCallbacks(testutil.mustRaise, eb)
        return d