Example #1
0
def test_092_set_smb_quota(request, proto):
    """
    This test checks our ability to set a ZFS quota
    through the SMB protocol by first setting a 2 GiB
    quota, then reading it through the SMB protocol, then
    resetting to zero.
    """
    depends(request, ["BA_ADDED_TO_USER"])
    new_quota = 2 * (2**30)
    c = SMB()
    qt = c.set_quota(host=ip,
                     share=SMB_NAME,
                     username=SMB_USER,
                     password=SMB_PWD,
                     hardlimit=new_quota,
                     target=SMB_USER,
                     smb1=(proto == "SMB1"))
    assert len(qt) == 1, qt
    assert qt[0]['user'].endswith(SMB_USER), qt
    assert qt[0]['soft_limit'] == new_quota, qt
    assert qt[0]['hard_limit'] == new_quota, qt

    qt = c.get_quota(host=ip,
                     share=SMB_NAME,
                     username=SMB_USER,
                     password=SMB_PWD,
                     smb1=(proto == "SMB1"))
    assert len(qt) == 1, qt
    assert qt[0]['user'].endswith(SMB_USER), qt
    assert qt[0]['soft_limit'] == new_quota, qt
    assert qt[0]['hard_limit'] == new_quota, qt

    qt = c.set_quota(host=ip,
                     share=SMB_NAME,
                     username=SMB_USER,
                     password=SMB_PWD,
                     hardlimit=-1,
                     target=SMB_USER,
                     smb1=(proto == "SMB1"))
    assert len(qt) == 1, qt
    assert qt[0]['user'].endswith(SMB_USER), qt
    assert qt[0]['soft_limit'] is None, qt
    assert qt[0]['hard_limit'] is None, qt

    qt = c.get_quota(host=ip,
                     share=SMB_NAME,
                     username=SMB_USER,
                     password=SMB_PWD,
                     smb1=(proto == "SMB1"))
    assert len(qt) == 1, qt
    assert qt[0]['user'].endswith(SMB_USER), qt
    assert qt[0]['soft_limit'] is None, qt
    assert qt[0]['hard_limit'] is None, qt
Example #2
0
def test_090_test_auto_smb_quota(request, proto):
    """
    Since the share is configured wtih ixnas:base_user_quota parameter,
    the first SMB tree connect should have set a ZFS user quota on the
    underlying dataset. Test querying through the SMB protocol.

    Currently SMB1 protocol is disabled because of hard-coded check in
    source3/smbd/nttrans.c to only allow root to get/set quotas.
    """
    depends(request, ["BA_ADDED_TO_USER"])
    c = SMB()
    qt = c.get_quota(host=ip,
                     share=SMB_NAME,
                     username=SMB_USER,
                     password=SMB_PWD,
                     smb1=(proto == "SMB1"))

    # There should only be one quota entry
    assert len(qt) == 1, qt

    # username is prefixed with server netbios name "SERVER\user"
    assert qt[0]['user'].endswith(SMB_USER), qt

    # Hard and Soft limits should be set to value above (1GiB)
    assert qt[0]['soft_limit'] == (2**30), qt
    assert qt[0]['hard_limit'] == (2**30), qt