Beispiel #1
0
  def setup_class(klass):
    """ Run once per test class before any tests are run """
    rc = basicSetup()

    assert checkRC(rc, "basic setup")

    klass.orgsCreated = []
    klass.orgMap = {}

    klass.dwc = rc.dwc
    klass.superToken = rc.superToken

    # Create a new org.
    rc = klass.dwc.orgCreate("Alice's House of Grues",
                             "Alice", "*****@*****.**", "aliceRules",
                             isATest=True)

    assert checkRC(rc, "create org")

    klass.orgID = rc.orgID
    assert klass.orgID

    klass.orgAdminCred = rc.cred
    assert klass.orgAdminCred

    klass.orgAdminToken = rc.token
    assert klass.orgAdminToken

    klass.orgCreated(klass.orgID, "Alice's House of Grues",
                     "*****@*****.**", klass.orgAdminToken)
Beispiel #2
0
  def test_makeURL(self):
    rc = basicSetup()

    assert checkRC(rc, "basic setup")

    url = rc.dwc.makeURL("auth", "_000000000", "alice")
    assert url == (BaseURL + "/auth/_000000000/alice")
Beispiel #3
0
  def test_400_orgsList(self):
    # Create some new orgs.
    for orgName, adminName, adminEmail, adminPassword in [
      ( "Bob's House o' Fishin' Tackle n' Certifyin' Authori-tie",
        'Bob', '*****@*****.**', 'bobRules' ),
      ( "Eve's Espionage Emporium",
        'Eve', '*****@*****.**', 'eveRules' ),
      ( "Mallet's Hardware Hut",
        'Mallet', '*****@*****.**', 'malletRules' ),
      ( "Alice's Grue Supply",
        'Alice', '*****@*****.**', 'aliceRules' )
    ]:
      rc = self.dwc.orgCreate(orgName, adminName, adminEmail, adminPassword, isATest=True)

      assert checkRC(rc, "create org")

      assert rc.orgID
      assert rc.cred
      assert rc.token

      TestRegistrationService.orgCreated(rc.orgID, orgName, adminEmail, rc.token)

    # Let the world settle. Sigh.
    print("settling the world")
    time.sleep(5)

    # After creating the orgs, try for a list.
    #
    # XXX
    # For right now this uses a magic super-admin token which you cannot get via the
    # registrar. It must be generated OOB by hand. Talk to Flynn about how.

    rc = self.dwc.orgList(self.superToken)

    assert checkRC(rc, "list orgs")

    assert rc.orgIDs

    createdOrgIDs = [ orgTuple[0] for orgTuple in TestRegistrationService.orgsCreated]
    createdList = ",".join(sorted(createdOrgIDs))
    readList = ",".join(sorted(rc.orgIDs))

    if createdList != readList:
      print("Created orgs: %s" % createdList)
      print("Read back:    %s" % readList)

    assert createdList == readList
Beispiel #4
0
  def test_200_goodAuth(self):
    rc = self.dwc.userAuth('*****@*****.**', 'aliceRules')

    assert checkRC(rc, "userAuth alice")
    assert rc.orgID == self.orgID

    assert rc.cred
    assert rc.token
Beispiel #5
0
  def test_300_serviceCreate(self):
    # Explicitly auth as Eve
    rc = self.dwc.userAuth('*****@*****.**', 'eveRules', orgID=self.orgID)

    assert checkRC(rc, "userAuth eve")
    assert rc.orgID == self.orgID

    assert rc.cred
    assert rc.token

    # Try for a service.
    rc = self.dwc.serviceCreate(self.orgID, rc.token, 'grueLocator')

    assert checkRC(rc, "serviceCreate grueLocator")

    assert rc.cred

    svcToken = rc.token
    assert svcToken

    rc = self.dwc.serviceCheck(self.orgID, svcToken, 'grueLocator')

    assert checkRC(rc, "serviceCheck grueLocator")

    rc = self.dwc.serviceCheck(self.orgID, svcToken, 'grueAvoider')

    assert checkNotRC(rc, "serviceCheck grueAvoider")

    rc = self.dwc.serviceCheck(self.orgID, svcToken + svcToken, 'grueLocator')

    assert checkNotRC(rc, "serviceCheck bad token (1)")

    c = chr(ord(svcToken[52]) + 1)

    badToken = svcToken[0:52] + c + svcToken[53:]

    rc = self.dwc.serviceCheck(self.orgID, badToken, 'grueLocator')

    assert checkNotRC(rc, "serviceCheck bad token (2)")