def test_license(self):
        old_lic = None
        old_sig = None
        try:
            old_lic, old_sig = self.getCurrentLicense()
        except InvalidLicenseException as exx:
            if (exx.message != "Support not available, your product is "
                    "unlicensed"):
                raise exx

        try:
            # Load the license file...
            licfile = config.get('monitoringTests.licfile', '')

            if not licfile:
                self.skipTest('Path to test license file is not configured, '
                              'check your configuration (test.ini)!')

            with request_context_safety():
                context['translate'] = lambda x: x
                lic_dict, lic_sig = readLicenseInfo(licfile)

            self.installLicense(licfile)

            self.create_token(serial='0031')
            self.create_token(serial='0032', user='******')
            self.create_token(serial='0033', realm='mydefrealm')
            self.create_token(serial='0034', realm='myotherrealm')
            self.create_token(serial='0035',
                              realm='myotherrealm',
                              active=False)
            self.create_token(serial='0036',
                              realm='myotherrealm',
                              user='******',
                              active=False)

            response = self.make_authenticated_request(controller='monitoring',
                                                       action='license',
                                                       params={})
            resp = json.loads(response.body)
            value = resp.get('result').get('value')
            self.assertEqual(value.get('token-num'),
                             int(lic_dict.get('token-num')), response)
            token_left = int(lic_dict.get('token-num')) - 4
            self.assertEqual(value.get('token-left'), token_left, response)

        finally:
            # restore previous license...
            if old_lic and old_sig:
                self.setCurrentLicense(old_lic, old_sig)

        return
Beispiel #2
0
    def test_license(self):
        old_lic = None
        old_sig = None
        try:
            old_lic, old_sig = self.getCurrentLicense()
        except InvalidLicenseException as exx:
            if (exx.message != "Support not available, your product is "
                    "unlicensed"):
                raise exx

        try:
            # Load the license file...
            licfile = config.get('monitoringTests.licfile', '')

            if not licfile:
                self.skipTest('Path to test license file is not configured, '
                              'check your configuration (test.ini)!')

            with request_context_safety():
                context['translate'] = lambda x: x
                lic_dict, lic_sig = readLicenseInfo(licfile)

            self.installLicense(licfile)

            self.create_token(serial='0031')
            self.create_token(serial='0032', user='******')
            self.create_token(serial='0033', realm='mydefrealm')
            self.create_token(serial='0034', realm='myotherrealm')
            self.create_token(serial='0035', realm='myotherrealm',
                              active=False)
            self.create_token(serial='0036', realm='myotherrealm', user='******',
                              active=False)

            response = self.make_authenticated_request(controller='monitoring',
                                                       action='license',
                                                       params={})
            resp = json.loads(response.body)
            value = resp.get('result').get('value')
            self.assertEqual(value.get('token-num'),
                             int(lic_dict.get('token-num')),
                             response)
            token_left = int(lic_dict.get('token-num')) - 4
            self.assertEqual(value.get('token-left'), token_left, response)

        finally:
            # restore previous license...
            if old_lic and old_sig:
                self.setCurrentLicense(old_lic, old_sig)

        return
Beispiel #3
0
 def installLicense(self, licfile):
     new_lic, new_sig = readLicenseInfo(licfile)
     setSupportLicenseInfo(new_lic, new_sig)
     return
Beispiel #4
0
 def installLicense(self, licfile):
     with request_context_safety():
         context['translate'] = lambda x: x
         new_lic, new_sig = readLicenseInfo(licfile)
         setSupportLicenseInfo(new_lic, new_sig)
         return
Beispiel #5
0
 def installLicense(self, licfile):
     with request_context_safety():
         context['translate'] = lambda x: x
         new_lic, new_sig = readLicenseInfo(licfile)
         setSupportLicenseInfo(new_lic, new_sig)
         return
Beispiel #6
0
 def installLicense(self, licfile):
     new_lic, new_sig = readLicenseInfo(licfile)
     setSupportLicenseInfo(new_lic, new_sig)