def dnsNamesTest():
    obj = dsslib.getConnection(CALLER)
    result = 0
    longHundredChars = 'a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789'
    longFiftyChars = 'a123456789a123456789a123456789a123456789a123456789'
    longTFTchars = longHundredChars + longHundredChars + longFiftyChars + 'qwe'
    try:
        obj.create_bucket(longTFTchars)
        obj.delete_bucket(longTFTchars)
        print "Able to create bucket with 253 chars in name"
    except:
        print "Failed to create or delete a valid bucket name"
        print "Unexpected error: ", sys.exc_info()
        return -1

    try:
        badName = longTFTchars + 'abc'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with illegally long name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating 256 char bucket name"
        print "Expected error: ", sys.exc_info()

    try:
        badName = 'Abc'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with capital letter name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating bucket name with CAPS"
        print "Expected error: ", sys.exc_info()

    try:
        badName = 'bc/'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with slash in name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating bucket name with slash"
        print "Expected error: ", sys.exc_info()

    return result
Example #2
0
def dnsNamesTest():
    obj = dsslib.getConnection(CALLER)
    result = 0
    longHundredChars = 'a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789a123456789'
    longFiftyChars = 'a123456789a123456789a123456789a123456789a123456789'
    longTFTchars = longHundredChars + longHundredChars + longFiftyChars + 'qwe'
    try:
        obj.create_bucket(longTFTchars)
        obj.delete_bucket(longTFTchars)
        print "Able to create bucket with 253 chars in name"
    except:
        print "Failed to create or delete a valid bucket name"
        print "Unexpected error: ", sys.exc_info()
        return -1

    try:
        badName = longTFTchars + 'abc'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with illegally long name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating 256 char bucket name"
        print "Expected error: ", sys.exc_info()

    try:
        badName = 'Abc'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with capital letter name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating bucket name with CAPS"
        print "Expected error: ", sys.exc_info()

    try:
        badName = 'bc/'
        obj.create_bucket(badName)
        print "Unexpectedly created bucket with slash in name"
        dsslib.listBucketNum(obj, "user3")
        dsslib.listBucket(obj, "user3")
        obj.delete_bucket(badName)
        result = -1
    except:
        print "Expected failure in creating bucket name with slash"
        print "Expected error: ", sys.exc_info()

    return result
Example #3
0
import sys
import time
import dsslib
import math, os
from boto.s3.key import Key
from filechunkio import FileChunkIO

dsslib.GLOBAL_DEBUG = 1

'''=========================================================
### API Doc testing
'''
usr_str = "user804"
obj = dsslib.getConnection(dsslib.USER_keystone804)
dsslib.listBucket(obj, usr_str)
b = obj.create_bucket('docsbuck001')
dsslib.listBucket(obj, usr_str)
b.set_acl('public-read-write')

k = Key(b)
k.key = 'obj1'
k.set_contents_from_string('Data of object')
print "Setting ACL on obj"
k.set_acl('public-read')

print "\nObject has ACL============="
print str(k.get_acl())
##====================================================================


'''=========================================================
Example #4
0
import sys
import time
import dsslib
import math, os
from boto.s3.key import Key
from filechunkio import FileChunkIO

dsslib.GLOBAL_DEBUG = 1
'''=========================================================
### API Doc testing
'''
usr_str = "user804"
obj = dsslib.getConnection(dsslib.USER_keystone804)
dsslib.listBucket(obj, usr_str)
b = obj.create_bucket('docsbuck001')
dsslib.listBucket(obj, usr_str)
b.set_acl('public-read-write')

k = Key(b)
k.key = 'obj1'
k.set_contents_from_string('Data of object')
print "Setting ACL on obj"
k.set_acl('public-read')

print "\nObject has ACL============="
print str(k.get_acl())
##====================================================================
'''=========================================================
## AWS user policy prevents user from listing bucket but allows getting objects inside the particular bucket
## Make listing buckets allowed. Generate signed URLs then make listing buckets not allowed in user policy.
## Check if the URLs still work.