Пример #1
0
    def test_WINNF_FT_S_SDS_18(self):
        """Invalid certificate following an approved grant request.

    Checks that SAS UUT response with fatal alert message.
    """
        # Reset the SAS UUT
        self.SasReset()

        device_cert_name = "short_lived_domain_proxy"
        cert_duration_minutes = 1  # in minutes

        # Create a short lived certificate signed by intermediate DP CA.
        self.createShortLivedCertificate("DomainProxy", device_cert_name,
                                         cert_duration_minutes)

        # Get the absoulte path of short lived certificate.
        domain_proxy_cert = getCertFilename(device_cert_name + ".cert")
        domain_proxy_key = getCertFilename(device_cert_name + ".key")

        # Successful TLS Handshake.
        # This uses the same base_url as Registration().
        self.assertTlsHandshakeSucceed(self._sas.cbsd_sas_active_base_url,
                                       ['AES128-GCM-SHA256'],
                                       domain_proxy_cert, domain_proxy_key)
        logging.info("TLS Handshake Succeeded")

        # Load the device_a file
        device_a = json.load(
            open(os.path.join('testcases', 'testdata', 'device_a.json')))

        # Load the grant_0 file
        grant_0 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))

        # Device is registered with short live certificate and ensure that response is successful.
        # The CiphersOverload approach is used in to override the default certificates with
        # the certificates configured for this test case.
        with security_testcase.CiphersOverload(self._sas,
                                               self._sas._tls_config.ciphers,
                                               domain_proxy_cert,
                                               domain_proxy_key):
            cbsd_ids, grant_ids = self.assertRegisteredAndGranted([device_a],
                                                                  [grant_0])

        logging.info("CBSD device is in Granted State")

        # Wait for the short lived certificate to expire.
        wait_timer = (cert_duration_minutes * 60) + 5
        logging.info(
            "Waiting for %s secs so the certificate will become invalid",
            wait_timer)
        time.sleep(wait_timer)

        # Verify TLS handshake fails.
        logging.info(
            "CBSD attempts to re-establish TLS Handshake with SAS UUT")
        self.assertTlsHandshakeFailureOrHttp403(client_cert=domain_proxy_cert,
                                                client_key=domain_proxy_key)
        logging.info(
            "TLS handshake failed as the domain proxy certificate is invalid")
Пример #2
0
    def generate_SDS_12_default_config(self, filename):
        """Generates the WinnForum configuration for SDS.12"""
        # Create the actual config for domain proxy cert/key path

        config = {
            'domainProxyCert': getCertFilename("domain_proxy_expired.cert"),
            'domainProxyKey': getCertFilename("domain_proxy_expired.key")
        }
        writeConfig(filename, config)
Пример #3
0
  def generate_SCS_6_default_config(self, filename):
    """Generates the WinnForum configuration for SCS_6"""
    # Create the actual config for client cert/key path

    config = {
      'clientCert': getCertFilename("unrecognized_device.cert"),
      'clientKey': getCertFilename("unrecognized_device.key")
    }
    writeConfig(filename, config)
Пример #4
0
    def generate_SDS_10_default_config(self, filename):
        """Generates the WinnForum configuration for SDS_10. """
        # Create the actual config for domain proxy cert/key path

        config = {
            'domainProxyCert': getCertFilename("domain_proxy_wrong_type.cert"),
            'domainProxyKey': getCertFilename("server.key")
        }
        writeConfig(filename, config)
Пример #5
0
    def generate_SSS_11_default_config(self, filename):
        """Generate the WinnForum configuration for SSS_11."""
        # Create the configuration for blacklisted SAS cert/key path.

        config = {
            'sasCert': getCertFilename("sas_blacklisted.cert"),
            'sasKey': getCertFilename("sas_blacklisted.key")
        }
        writeConfig(filename, config)
Пример #6
0
 def generate_SCS_15_default_config(self, filename):
   """ Generates the WinnForum configuration for SCS.15 """
   # Create the actual config for client cert/key path
   
   config = {
       'clientCert': getCertFilename("device_inapplicable.cert"),
       'clientKey': getCertFilename("device_a.key")
   }
   writeConfig(filename, config)
Пример #7
0
    def generate_SSS_15_default_config(self, filename):
        """Generates the WinnForum configuration for SSS_15. """
        # Create the actual config for SAS cert/key path

        config = {
            'sasCert': getCertFilename("sas_inapplicable.cert"),
            'sasKey': getCertFilename("sas.key")
        }
        writeConfig(filename, config)
Пример #8
0
    def generate_SSS_16_default_config(self, filename):
        """Generate the WinnForum configuration for SSS_16."""
        # Create the configuration for SAS cert/key path.

        config = {
            'sasCert': getCertFilename("sas_cert_from_revoked_ca.cert"),
            'sasKey': getCertFilename("sas_cert_from_revoked_ca.key")
        }
        writeConfig(filename, config)
Пример #9
0
  def test_WINNF_FT_S_SCS_5(self):
    """New registration with TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher.

    Checks that SAS UUT response satisfy specific security conditions.
    Checks that a CBSD registration with this configuration succeed.
    """
    self.doCbsdTestCipher('ECDHE-RSA-AES128-GCM-SHA256',
                          getCertFilename("device_a.cert"),
                          getCertFilename("device_a.key"))
Пример #10
0
  def generate_SCS_16_default_config(self, filename):
    """Generate the WinnForum configuration for SCS_16."""
    # Create the configuration for client cert/key path.

    config = {
        'clientCert': getCertFilename("device_cert_from_revoked_ca.cert"),
        'clientKey': getCertFilename("device_cert_from_revoked_ca.key")
    }
    writeConfig(filename, config)
Пример #11
0
  def test_WINNF_FT_S_SCS_13(self):
    """ Disallowed TLS method attempted during registration.

    Checks that SAS UUT response with fatal alert message.
    """
    self.assertTlsHandshakeFailureOrHttp403(
        ssl_method=SSL.TLSv1_1_METHOD,
        client_cert=getCertFilename('device_a.cert'),
        client_key=getCertFilename('device_a.key'))
Пример #12
0
  def test_WINNF_FT_S_SCS_14(self):
    """Invalid ciphersuite presented during registration.

    Checks that SAS UUT response with fatal alert message.
    """
    self.assertTlsHandshakeFailureOrHttp403(
        ciphers='ECDHE-RSA-AES256-GCM-SHA384',
        client_cert=getCertFilename('device_a.cert'),
        client_key=getCertFilename('device_a.key'))
Пример #13
0
  def generate_SCS_11_default_config(self, filename):
    """Generate the WinnForum configuration for SCS_11."""
    # Create the configuration for blacklisted client cert/key path

    config = {
        'clientCert': getCertFilename("device_blacklisted.cert"),
        'clientKey': getCertFilename("device_blacklisted.key")
    }
    writeConfig(filename, config)
Пример #14
0
  def generate_SCS_7_default_config(self, filename):
    """Generates the WinnForum configuration for SCS_7"""
    # Create the actual config for client cert/key path

    config = {
      'clientCert': getCertFilename("device_corrupted.cert"),
      'clientKey': getCertFilename("device_corrupted.key")
    }
    writeConfig(filename, config)
Пример #15
0
    def generate_SSS_10_default_config(self, filename):
        """Generates the WinnForum configuration for SSS_10. """
        # Create the actual config for SAS cert/key path

        config = {
            'sasCert': getCertFilename("sas_wrong_type.cert"),
            'sasKey': getCertFilename("device_a.key")
        }
        writeConfig(filename, config)
Пример #16
0
    def generate_SSS_6_default_config(self, filename):
        """Generates the WinnForum configuration for SSS_6"""
        # Create the actual config for SAS cert/key path

        config = {
            'sasCert': getCertFilename("unrecognized_sas.cert"),
            'sasKey': getCertFilename("unrecognized_sas.key")
        }
        writeConfig(filename, config)
Пример #17
0
    def generate_SDS_6_default_config(self, filename):
        """Generates the WinnForum configuration for SDS_6"""
        # Create the actual config for domain proxy cert/key path

        config = {
            'domainProxyCert':
            getCertFilename("unrecognized_domain_proxy.cert"),
            'domainProxyKey': getCertFilename("unrecognized_domain_proxy.key")
        }
        writeConfig(filename, config)
Пример #18
0
    def generate_SDS_11_default_config(self, filename):
        """Generate the WinnForum configuration for SDS_11."""
        # Create the configuration for blacklisted domain proxy cert/key path.

        config = {
            'domainProxyCert':
            getCertFilename("domain_proxy_blacklisted.cert"),
            'domainProxyKey': getCertFilename("domain_proxy_blacklisted.key")
        }
        writeConfig(filename, config)
Пример #19
0
  def generate_SCS_10_default_config(self, filename):
    """Generates the WinnForum configuration for SCS_10. """
    # Create the actual config for client cert/key path

    config = {
      'clientCert': getCertFilename("device_wrong_type.cert"),
      'clientKey': getCertFilename("server.key")

    }
    writeConfig(filename, config)
Пример #20
0
  def test_WINNF_FT_S_SCS_19(self):
    """Invalid certificate following an approved heartbeat request.

    Checks that SAS UUT response with fatal alert message.
    """
    # Reset the SAS UUT
    self.SasReset()

    device_cert_name = "short_lived_client"
    cert_duration_minutes = 1  # in minutes

    # Create a short lived certificate signed by intermediate CBSD CA.
    self.createShortLivedCertificate("CBSD", device_cert_name, cert_duration_minutes)

    # Get the absolute path of the short lived certificate created.
    device_cert = getCertFilename(device_cert_name + ".cert")
    device_key = getCertFilename(device_cert_name + ".key")

    # Successful TLS Handshake.
    # This uses the same base_url as Registration().
    self.assertTlsHandshakeSucceed(self._sas.cbsd_sas_active_base_url,
                                   ['AES128-GCM-SHA256'],
                                   device_cert, device_key)
    logging.info("TLS Handshake Succeeded")

    # Load the device_a file.
    device_a = json.load(open(os.path.join('testcases', 'testdata', 'device_a.json')))

    # Load the grant_0 file.
    grant_0 = json.load(open(os.path.join('testcases', 'testdata', 'grant_0.json')))

    # Register device and grant device with certs(short lived certificates) to SAS UUT.
    # Ensure the registration and grant requests are successful.
    # The CiphersOverload approach is used in to override the default certificates with
    # the certificates configured for this test case.
    with security_testcase.CiphersOverload(self._sas, self._sas._tls_config.ciphers,
                                           device_cert, device_key):
      cbsd_ids, grant_ids = self.assertRegisteredAndGranted([device_a], [grant_0])
      operation_states = ['GRANTED']

      # Send the Heartbeat request for the Grant of CBSD to SAS UUT.
      transmit_expire_time = self.assertHeartbeatsSuccessful(cbsd_ids, grant_ids, operation_states)

    logging.info("CBSD is in HeartBeat Successful State")

    # Wait for the short lived certificate to expire.
    wait_timer = (cert_duration_minutes * 60) + 5
    logging.info("Waiting for %s secs so the certificate will become invalid", wait_timer)
    time.sleep(wait_timer)

    # Verify TLS handshake fails.
    logging.info("CBSD attempts to re-establish TLS Handshake with SAS UUT")
    self.assertTlsHandshakeFailureOrHttp403(client_cert=device_cert, client_key=device_key)
    logging.info("TLS handshake failed as the client certificate is invalid")
Пример #21
0
    def generate_SDS_16_default_config(self, filename):
        """Generate the WinnForum configuration for SDS_16."""
        # Create the configuration for domain proxy cert/key path.

        config = {
            'domainProxyCert':
            getCertFilename("domain_proxy_cert_from_revoked_ca.cert"),
            'domainProxyKey':
            getCertFilename("domain_proxy_cert_from_revoked_ca.key")
        }
        writeConfig(filename, config)
Пример #22
0
    def generate_SSS_18_default_config(self, filename):
        """ Generates the WinnForum configuration for SSS.18 """
        # Create the actual config for SAS cert/key path

        valid_cert_key_pair = {
            'cert': getCertFilename('sas.cert'),
            'key': getCertFilename('sas.key')
        }
        invalid_cert_key_pair = {
            'cert': getCertFilename('sas_expired.cert'),
            'key': getCertFilename('sas_expired.key')
        }

        config = {
            'validCertKeyPair': valid_cert_key_pair,
            'invalidCertKeyPair': invalid_cert_key_pair
        }
        writeConfig(filename, config)
    def generate_FAD_1_default_config(self, filename):
        """Generates the WinnForum configuration for FAD.1"""
        # Load device info
        device_a = json.load(
            open(os.path.join('testcases', 'testdata', 'device_a.json')))
        device_b = json.load(
            open(os.path.join('testcases', 'testdata', 'device_b.json')))
        device_c = json.load(
            open(os.path.join('testcases', 'testdata', 'device_c.json')))
        # Device #2 is Category B
        # pre-loaded.
        self.assertEqual(device_b['cbsdCategory'], 'B')
        conditionals_b = {
            'cbsdCategory': device_b['cbsdCategory'],
            'fccId': device_b['fccId'],
            'cbsdSerialNumber': device_b['cbsdSerialNumber'],
            'airInterface': device_b['airInterface'],
            'installationParam': device_b['installationParam']
        }
        conditionals = {'registrationData': [conditionals_b]}
        del device_b['cbsdCategory']
        del device_b['airInterface']
        del device_b['installationParam']
        devices = [device_a, device_b, device_c]
        # Grants
        grants = []
        for index in range(len(devices)):
            grants.append(
                json.load(
                    open(os.path.join('testcases', 'testdata',
                                      'grant_0.json'))))
        # PPAs and PALs
        ppas = []
        pals = []
        pal_low_frequency = 3550000000.0
        pal_high_frequency = 3560000000.0
        pal_record = json.load(
            open(os.path.join('testcases', 'testdata', 'pal_record_0.json')))
        ppa_record = json.load(
            open(os.path.join('testcases', 'testdata', 'ppa_record_0.json')))
        ppa, pal = makePpaAndPalRecordsConsistent(ppa_record, [pal_record],
                                                  pal_low_frequency,
                                                  pal_high_frequency,
                                                  device_a['userId'])

        device_a['installationParam']['latitude'], device_a[
            'installationParam']['longitude'] = getRandomLatLongInPolygon(ppa)
        # Devices inside and part of the claimed PPA.
        # Contains the index of devices in the devices list.
        ppas.append({'ppaRecord': ppa, 'ppaClusterList': [0]})
        pals.extend(pal)
        # ESC senosrs
        esc_sensors = []
        esc_sensors.append(
            json.load(
                open(
                    os.path.join('testcases', 'testdata',
                                 'esc_sensor_record_0.json'))))
        # SAS test harness configuration
        sas_test_harness_0_config = {
            'sasTestHarnessName': 'SAS-TH-2',
            'hostName': getFqdnLocalhost(),
            'port': getUnusedPort(),
            'serverCert': getCertFilename('sas.cert'),
            'serverKey': getCertFilename('sas.key'),
            'caCert': "certs/ca.cert"
        }
        sas_test_harness_1_config = {
            'sasTestHarnessName': 'SAS-TH-2',
            'hostName': getFqdnLocalhost(),
            'port': getUnusedPort(),
            'serverCert': getCertFilename('sas_1.cert'),
            'serverKey': getCertFilename('sas_1.key'),
            'caCert': getCertFilename('ca.cert')
        }
        config = {
            'registrationRequests':
            devices,
            'conditionalRegistrationData':
            conditionals,
            'grantRequests':
            grants,
            'ppaRecords':
            ppas,
            'palRecords':
            pals,
            'escSensorRecords':
            esc_sensors,
            'sasTestHarnessConfigs':
            [sas_test_harness_0_config, sas_test_harness_1_config]
        }
        writeConfig(filename, config)
  def generate_GPR_2_default_config(self, filename):
    """ Generates the WinnForum configuration for GPR.2. """

    # Load GWPZ Record
    gwpz_record_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'gwpz_record_0.json')))

    # Load devices info
    device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    # Moving device_1 to a location within 40 KMs of GWPZ zone
    device_1['installationParam']['latitude'] = 39.10448
    device_1['installationParam']['longitude'] = -99.7792

    device_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_b.json')))
    # Moving device_2 to a location outside 40 KMs of GWPZ zone
    device_2['installationParam']['latitude'] = 37.83075
    device_2['installationParam']['longitude'] = -107.65025

    device_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_c.json')))
    # Moving device_3 to a location inside GWPZ zone
    device_3['installationParam']['latitude'], \
    device_3['installationParam']['longitude'] = getRandomLatLongInPolygon(gwpz_record_1)

    device_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_d.json')))
    # Moving device_4 to a location outside 40 KMs of GWPZ zone
    device_4['installationParam']['latitude'] = 38.0934
    device_4['installationParam']['longitude'] = -106.91676

    # Load Grant requests
    grant_request_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))
    grant_request_1['operationParam']['operationFrequencyRange']['lowFrequency'] = 3650000000
    grant_request_1['operationParam']['operationFrequencyRange']['highFrequency'] = 3655000000

    grant_request_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_1.json')))
    grant_request_2['operationParam']['operationFrequencyRange']['lowFrequency'] = 3660000000
    grant_request_2['operationParam']['operationFrequencyRange']['highFrequency'] = 3665000000

    grant_request_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_2.json')))
    grant_request_3['operationParam']['operationFrequencyRange']['lowFrequency'] = 3670000000
    grant_request_3['operationParam']['operationFrequencyRange']['highFrequency'] = 3680000000

    grant_request_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))
    grant_request_4['operationParam']['operationFrequencyRange']['lowFrequency'] = 3690000000
    grant_request_4['operationParam']['operationFrequencyRange']['highFrequency'] = 3700000000

    # device_b and device_d are Category B
    # Load Conditional Data
    self.assertEqual(device_2['cbsdCategory'], 'B')
    conditionals_device_2 = {
        'cbsdCategory': device_2['cbsdCategory'],
        'fccId': device_2['fccId'],
        'cbsdSerialNumber': device_2['cbsdSerialNumber'],
        'airInterface': device_2['airInterface'],
        'installationParam': device_2['installationParam'],
        'measCapability': device_2['measCapability']
    }

    self.assertEqual(device_4['cbsdCategory'], 'B')
    conditionals_device_4 = {
        'cbsdCategory': device_4['cbsdCategory'],
        'fccId': device_4['fccId'],
        'cbsdSerialNumber': device_4['cbsdSerialNumber'],
        'airInterface': device_4['airInterface'],
        'installationParam': device_4['installationParam'],
        'measCapability': device_4['measCapability']
    }

    # Remove conditionals from registration
    del device_2['cbsdCategory']
    del device_2['airInterface']
    del device_2['installationParam']
    del device_2['measCapability']
    del device_4['cbsdCategory']
    del device_4['airInterface']
    del device_4['installationParam']
    del device_4['measCapability']

    # Registration and grant records
    cbsd_records_domain_proxy_0 = {
        'registrationRequests': [device_1, device_2],
        'grantRequests': [grant_request_1, grant_request_2],
        'conditionalRegistrationData': [conditionals_device_2]
    }
    cbsd_records_domain_proxy_1 = {
        'registrationRequests': [device_3],
        'grantRequests': [grant_request_3],
        'conditionalRegistrationData': []
    }

    # Protected entity record
    protected_entities = {
        'gwpzRecords': [gwpz_record_1]
    }

    # SAS Test Harnesses configurations,
    # Following configurations are for two SAS test harnesses
    sas_test_harness_device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    sas_test_harness_device_1['fccId'] = "test_fcc_id_e"
    sas_test_harness_device_1['userId'] = "test_user_id_e"

    sas_test_harness_device_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_b.json')))
    sas_test_harness_device_2['fccId'] = "test_fcc_id_f"
    sas_test_harness_device_2['userId'] = "test_user_id_f"

    sas_test_harness_device_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_c.json')))
    sas_test_harness_device_3['fccId'] = "test_fcc_id_g"
    sas_test_harness_device_3['userId'] = "test_user_id_g"

    # Generate Cbsd FAD Records for SAS Test Harness 0
    cbsd_fad_records_sas_test_harness_0 = generateCbsdRecords(
                                          [sas_test_harness_device_1],
                                          [[grant_request_1]]
    )

    # Generate Cbsd FAD Records for SAS Test Harness 1
    cbsd_fad_records_sas_test_harness_1 = generateCbsdRecords(
                                          [sas_test_harness_device_2, sas_test_harness_device_3],
                                          [[grant_request_2], [grant_request_3]]
    )

    # Generate SAS Test Harnesses dump records
    dump_records_sas_test_harness_0 = {
        'cbsdRecords': cbsd_fad_records_sas_test_harness_0
    }
    dump_records_sas_test_harness_1 = {
        'cbsdRecords': cbsd_fad_records_sas_test_harness_1
    }

    # SAS Test Harnesses configuration
    sas_test_harness_0_config = {
        'sasTestHarnessName': 'SAS-TH-1',
        'hostName': getFqdnLocalhost(),
        'port': getUnusedPort(),
        'serverCert': getCertFilename('sas.cert'),
        'serverKey': getCertFilename('sas.key'),
        'caCert': getCertFilename('ca.cert')
    }
    sas_test_harness_1_config = {
        'sasTestHarnessName': 'SAS-TH-2',
        'hostName': getFqdnLocalhost(),
        'port': getUnusedPort(),
        'serverCert': getCertFilename('sas_1.cert'),
        'serverKey': getCertFilename('sas_1.key'),
        'caCert': getCertFilename('ca.cert')
    }

    iteration_config = {
        'cbsdRequestsWithDomainProxies': [cbsd_records_domain_proxy_0,
                                          cbsd_records_domain_proxy_1],
        'cbsdRecords': [{
            'registrationRequest': device_4,
            'grantRequest': grant_request_4,
            'conditionalRegistrationData': conditionals_device_4,
            'clientCert': getCertFilename('device_d.cert'),
            'clientKey': getCertFilename('device_d.key')
        }],
        'protectedEntities': protected_entities,
        'dpaActivationList': [],
        'dpaDeactivationList': [],
        'sasTestHarnessData': [dump_records_sas_test_harness_0,
                               dump_records_sas_test_harness_1]
    }

    # Create the actual config.
    config = {
        'initialCbsdRequestsWithDomainProxies': self.getEmptyCbsdRequestsWithDomainProxies(2),
        'initialCbsdRecords': [],
        'iterationData': [iteration_config],
        'sasTestHarnessConfigs': [sas_test_harness_0_config,
                                  sas_test_harness_1_config],
        'domainProxyConfigs': [{
             'cert': getCertFilename('domain_proxy.cert'),
             'key': getCertFilename('domain_proxy.key')
        }, {
             'cert': getCertFilename('domain_proxy_1.cert'),
             'key': getCertFilename('domain_proxy_1.key')}]
    }
    writeConfig(filename, config)
  def generate_EPR_2_default_config(self, filename):
    """ Generates the WinnForum configuration for EPR.2. """

    # Load ESC record
    esc_record_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'esc_sensor_record_0.json')))

    # Load devices info
    device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    # Moving device_1(Cat A) to a location within 40 KMs of ESC sensor
    device_1['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.20
    device_1['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_b.json')))
    # Moving device_2(Cat B) to a location within 80 KMs of ESC sensor
    device_2['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.70
    device_2['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_c.json')))
    # Moving device_3(Cat A) to a location outside 40 KMs of ESC sensor
    device_3['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.50
    device_3['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_d.json')))
    # Moving device_4(Cat B) to a location outside 80 KMs of ESC sensor
    device_4['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 1.0
    device_4['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    # Load Grant requests with In-band frequency range for all devices
    grant_request_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))
    grant_request_1['operationParam']['operationFrequencyRange']['lowFrequency'] = 3550000000
    grant_request_1['operationParam']['operationFrequencyRange']['highFrequency'] = 3560000000

    grant_request_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_1.json')))
    grant_request_2['operationParam']['operationFrequencyRange']['lowFrequency'] = 3570000000
    grant_request_2['operationParam']['operationFrequencyRange']['highFrequency'] = 3580000000

    grant_request_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_2.json')))
    grant_request_3['operationParam']['operationFrequencyRange']['lowFrequency'] = 3590000000
    grant_request_3['operationParam']['operationFrequencyRange']['highFrequency'] = 3600000000

    grant_request_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))
    grant_request_4['operationParam']['operationFrequencyRange']['lowFrequency'] = 3610000000
    grant_request_4['operationParam']['operationFrequencyRange']['highFrequency'] = 3620000000

    # device_b and device_d are Category B
    # Load Conditional Data
    self.assertEqual(device_2['cbsdCategory'], 'B')
    conditionals_device_2 = {
        'cbsdCategory': device_2['cbsdCategory'],
        'fccId': device_2['fccId'],
        'cbsdSerialNumber': device_2['cbsdSerialNumber'],
        'airInterface': device_2['airInterface'],
        'installationParam': device_2['installationParam'],
        'measCapability': device_2['measCapability']
    }

    self.assertEqual(device_4['cbsdCategory'], 'B')
    conditionals_device_4 = {
        'cbsdCategory': device_4['cbsdCategory'],
        'fccId': device_4['fccId'],
        'cbsdSerialNumber': device_4['cbsdSerialNumber'],
        'airInterface': device_4['airInterface'],
        'installationParam': device_4['installationParam'],
        'measCapability': device_4['measCapability']
    }

    # Remove conditionals from registration
    del device_2['cbsdCategory']
    del device_2['airInterface']
    del device_2['installationParam']
    del device_2['measCapability']
    del device_4['cbsdCategory']
    del device_4['airInterface']
    del device_4['installationParam']
    del device_4['measCapability']

    # Registration and grant records
    cbsd_records_domain_proxy_0 = {
        'registrationRequests': [device_1, device_2],
        'grantRequests': [grant_request_1, grant_request_2],
        'conditionalRegistrationData': [conditionals_device_2]

    }
    cbsd_records_domain_proxy_1 = {
        'registrationRequests': [device_3],
        'grantRequests': [grant_request_3],
        'conditionalRegistrationData': []
    }

    # Protected entity record
    protected_entities = {
        'escRecords': [esc_record_1]
    }

    # SAS Test Harnesses configurations,
    # Following configurations are for two SAS test harnesses
    sas_test_harness_device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    sas_test_harness_device_1['fccId'] = "test_fcc_id_e"
    sas_test_harness_device_1['userId'] = "test_user_id_e"

    sas_test_harness_device_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_b.json')))
    sas_test_harness_device_2['fccId'] = "test_fcc_id_f"
    sas_test_harness_device_2['userId'] = "test_user_id_f"

    sas_test_harness_device_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_c.json')))
    sas_test_harness_device_3['fccId'] = "test_fcc_id_g"
    sas_test_harness_device_3['userId'] = "test_user_id_g"

    # Generate Cbsd FAD Records for SAS Test Harness 0
    cbsd_fad_records_sas_test_harness_0 = generateCbsdRecords(
                                          [sas_test_harness_device_1],
                                          [[grant_request_1]]
    )

    # Generate Cbsd FAD Records for SAS Test Harness 1
    cbsd_fad_records_sas_test_harness_1 = generateCbsdRecords(
                                          [sas_test_harness_device_2, sas_test_harness_device_3],
                                          [[grant_request_2], [grant_request_3]]
    )

    # Generate SAS Test Harnesses dump records
    dump_records_sas_test_harness_0 = {
        'cbsdRecords': cbsd_fad_records_sas_test_harness_0
    }
    dump_records_sas_test_harness_1 = {
        'cbsdRecords': cbsd_fad_records_sas_test_harness_1
    }

    # SAS Test Harnesses configuration
    sas_test_harness_0_config = {
        'sasTestHarnessName': 'SAS-TH-1',
        'hostName': getFqdnLocalhost(),
        'port': getUnusedPort(),
        'serverCert': getCertFilename('sas.cert'),
        'serverKey': getCertFilename('sas.key'),
        'caCert': getCertFilename('ca.cert')
    }
    sas_test_harness_1_config = {
        'sasTestHarnessName': 'SAS-TH-2',
        'hostName': getFqdnLocalhost(),
        'port': getUnusedPort(),
        'serverCert': getCertFilename('sas_1.cert'),
        'serverKey': getCertFilename('sas_1.key'),
        'caCert': getCertFilename('ca.cert')
    }

    iteration_config = {
        'cbsdRequestsWithDomainProxies': [cbsd_records_domain_proxy_0,
                                          cbsd_records_domain_proxy_1],
        'cbsdRecords': [{
            'registrationRequest': device_4,
            'grantRequest': grant_request_4,
            'conditionalRegistrationData': conditionals_device_4,
            'clientCert': getCertFilename('device_d.cert'),
            'clientKey': getCertFilename('device_d.key')
        }],
        'protectedEntities': protected_entities,
        'dpaActivationList': [],
        'dpaDeactivationList': [],
        'sasTestHarnessData': [dump_records_sas_test_harness_0,
                               dump_records_sas_test_harness_1]
    }

    # Create the actual config.
    config = {
        'initialCbsdRequestsWithDomainProxies': self.getEmptyCbsdRequestsWithDomainProxies(2),
        'initialCbsdRecords': [],
        'iterationData': [iteration_config],
        'sasTestHarnessConfigs': [
            sas_test_harness_0_config, sas_test_harness_1_config
        ],
        'domainProxyConfigs': [{
            'cert': getCertFilename('domain_proxy.cert'),
            'key': getCertFilename('domain_proxy.key')
        }, {
            'cert': getCertFilename('domain_proxy_1.cert'),
            'key': getCertFilename('domain_proxy_1.key')
        }]
    }
    writeConfig(filename, config)
  def generate_EPR_1_default_config(self, filename):
    """ Generates the WinnForum configuration for EPR.1. """

    # Load ESC record
    esc_record_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'esc_sensor_record_0.json')))

    # Load devices info
    device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    # Moving device_1(Cat A) to a location within 40 KMs of ESC sensor
    device_1['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.20
    device_1['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_2 = json.load(
        open(os.path.join('testcases', 'testdata', 'device_b.json')))
    # Moving device_2(Cat B) to a location within 80 KMs of ESC sensor
    device_2['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.70
    device_2['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_3 = json.load(
        open(os.path.join('testcases', 'testdata', 'device_c.json')))
    # Moving device_3(Cat A) to a location outside 40 KMs of ESC sensor
    device_3['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 0.50
    device_3['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    device_4 = json.load(
        open(os.path.join('testcases', 'testdata', 'device_d.json')))
    # Moving device_4(Cat B) to a location outside 80 KMs of ESC sensor
    device_4['installationParam'][
        'latitude'] = esc_record_1['installationParam']['latitude'] + 1.0
    device_4['installationParam'][
        'longitude'] = esc_record_1['installationParam']['longitude']

    # Load Grant requests
    # Loading grant_request_1 for device_1 with In-band frequency range of 3620 to 3630 MHz
    grant_request_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))

    # Loading grant_request_2 for device_2 with In-band frequency range of 3630 to 3640 MHz
    grant_request_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_1.json')))

    # Loading grant_request_3 for device_3 with Out-of-band frequency range of 3650 to 3660 MHz
    grant_request_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_2.json')))

    # Loading grant_request_4 for device_4 with In-band frequency range of 3620 to 3630 MHz
    grant_request_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))

    # device_b and device_d are Category B
    # Load Conditional Data
    self.assertEqual(device_2['cbsdCategory'], 'B')
    conditionals_device_2 = {
        'cbsdCategory': device_2['cbsdCategory'],
        'fccId': device_2['fccId'],
        'cbsdSerialNumber': device_2['cbsdSerialNumber'],
        'airInterface': device_2['airInterface'],
        'installationParam': device_2['installationParam'],
        'measCapability': device_2['measCapability']
    }

    self.assertEqual(device_4['cbsdCategory'], 'B')
    conditionals_device_4 = {
        'cbsdCategory': device_4['cbsdCategory'],
        'fccId': device_4['fccId'],
        'cbsdSerialNumber': device_4['cbsdSerialNumber'],
        'airInterface': device_4['airInterface'],
        'installationParam': device_4['installationParam'],
        'measCapability': device_4['measCapability']
    }

    # Remove conditionals from registration
    del device_2['cbsdCategory']
    del device_2['airInterface']
    del device_2['installationParam']
    del device_2['measCapability']
    del device_4['cbsdCategory']
    del device_4['airInterface']
    del device_4['installationParam']
    del device_4['measCapability']

    # Registration and grant records
    cbsd_records_domain_proxy_0 = {
        'registrationRequests': [device_1, device_2],
        'grantRequests': [grant_request_1, grant_request_2],
        'conditionalRegistrationData': [conditionals_device_2]
    }
    cbsd_records_domain_proxy_1 = {
        'registrationRequests': [device_3],
        'grantRequests': [grant_request_3],
        'conditionalRegistrationData': []
    }

    # Protected entity record
    protected_entities = {
        'escRecords': [esc_record_1]
    }

    iteration_config = {
        'cbsdRequestsWithDomainProxies': [cbsd_records_domain_proxy_0,
                                          cbsd_records_domain_proxy_1],
        'cbsdRecords': [{
            'registrationRequest': device_4,
            'grantRequest': grant_request_4,
            'conditionalRegistrationData': conditionals_device_4,
            'clientCert': getCertFilename('device_d.cert'),
            'clientKey': getCertFilename('device_d.key')
        }],
        'protectedEntities': protected_entities,
        'dpaActivationList': [],
        'dpaDeactivationList': [],
        'sasTestHarnessData': []
    }
    # Create the actual config.
    config = {
        'initialCbsdRequestsWithDomainProxies': self.getEmptyCbsdRequestsWithDomainProxies(2),
        'initialCbsdRecords': [],
        'iterationData': [iteration_config],
        'sasTestHarnessConfigs': [],
        'domainProxyConfigs': [{
            'cert': getCertFilename('domain_proxy.cert'),
            'key': getCertFilename('domain_proxy.key')
        }, {
            'cert': getCertFilename('domain_proxy_1.cert'),
            'key': getCertFilename('domain_proxy_1.key')
        }]
    }
    writeConfig(filename, config)
Пример #27
0
    def generate_PPR_1_default_config(self, filename):
        """ Generates the WinnForum configuration for PPR.1. """

        # Load PPA record
        ppa_record = json.load(
            open(os.path.join('testcases', 'testdata', 'ppa_record_0.json')))
        pal_record = json.load(
            open(os.path.join('testcases', 'testdata', 'pal_record_0.json')))

        pal_low_frequency = 3550000000
        pal_high_frequency = 3560000000

        ppa_record_1, pal_records_1 = makePpaAndPalRecordsConsistent(
            ppa_record, [pal_record], pal_low_frequency, pal_high_frequency,
            'test_user_1')

        # Load devices info
        device_1 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_a.json')))
        # Moving device_1 to a location within 40 KMs of PPA zone
        device_1['installationParam']['latitude'] = 38.8203
        device_1['installationParam']['longitude'] = -97.2741

        device_2 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_b.json')))
        # Moving device_2 to a location outside 40 KMs of PPA zone
        device_2['installationParam']['latitude'] = 39.31476
        device_2['installationParam']['longitude'] = -96.75139

        device_3 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_c.json')))
        # Moving device_3 to a location within PPA zone
        device_3['installationParam']['latitude'], \
        device_3['installationParam']['longitude'] = getRandomLatLongInPolygon(ppa_record_1)

        device_4 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_d.json')))
        # Moving device_4 to a location within PPA zone
        device_4['installationParam']['latitude'], \
        device_4['installationParam']['longitude'] = getRandomLatLongInPolygon(ppa_record_1)

        # Load Grant requests
        grant_request_1 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_request_1['operationParam']['operationFrequencyRange'][
            'lowFrequency'] = 3550000000
        grant_request_1['operationParam']['operationFrequencyRange'][
            'highFrequency'] = 3560000000

        grant_request_2 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_1.json')))
        grant_request_2['operationParam']['operationFrequencyRange'][
            'lowFrequency'] = 3550000000
        grant_request_2['operationParam']['operationFrequencyRange'][
            'highFrequency'] = 3560000000

        grant_request_3 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_2.json')))
        grant_request_3['operationParam']['operationFrequencyRange'][
            'lowFrequency'] = 3550000000
        grant_request_3['operationParam']['operationFrequencyRange'][
            'highFrequency'] = 3560000000

        grant_request_4 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_request_4['operationParam']['operationFrequencyRange'][
            'lowFrequency'] = 3550000000
        grant_request_4['operationParam']['operationFrequencyRange'][
            'highFrequency'] = 3560000000

        # device_b and device_d are Category B
        # Load Conditional Data
        self.assertEqual(device_2['cbsdCategory'], 'B')
        conditionals_device_2 = {
            'cbsdCategory': device_2['cbsdCategory'],
            'fccId': device_2['fccId'],
            'cbsdSerialNumber': device_2['cbsdSerialNumber'],
            'airInterface': device_2['airInterface'],
            'installationParam': device_2['installationParam'],
            'measCapability': device_2['measCapability']
        }

        self.assertEqual(device_4['cbsdCategory'], 'B')
        conditionals_device_4 = {
            'cbsdCategory': device_4['cbsdCategory'],
            'fccId': device_4['fccId'],
            'cbsdSerialNumber': device_4['cbsdSerialNumber'],
            'airInterface': device_4['airInterface'],
            'installationParam': device_4['installationParam'],
            'measCapability': device_4['measCapability']
        }

        # Remove conditionals from registration
        del device_2['cbsdCategory']
        del device_2['airInterface']
        del device_2['installationParam']
        del device_2['measCapability']
        del device_4['cbsdCategory']
        del device_4['airInterface']
        del device_4['installationParam']
        del device_4['measCapability']

        # Registration and grant records
        cbsd_records_domain_proxy_0 = {
            'registrationRequests': [device_1, device_2],
            'grantRequests': [grant_request_1, grant_request_2],
            'conditionalRegistrationData': [conditionals_device_2]
        }
        cbsd_records_domain_proxy_1 = {
            'registrationRequests': [device_3],
            'grantRequests': [grant_request_3],
            'conditionalRegistrationData': []
        }

        # Protected entity record
        protected_entities = {
            'palRecords': pal_records_1,
            'ppaRecords': [ppa_record_1]
        }

        iteration_config = {
            'cbsdRequestsWithDomainProxies':
            [cbsd_records_domain_proxy_0, cbsd_records_domain_proxy_1],
            'cbsdRecords': [{
                'registrationRequest': device_4,
                'grantRequest': grant_request_4,
                'conditionalRegistrationData': conditionals_device_4,
                'clientCert': getCertFilename('device_d.cert'),
                'clientKey': getCertFilename('device_d.key')
            }],
            'protectedEntities':
            protected_entities,
            'dpaActivationList': [],
            'dpaDeactivationList': [],
            'sasTestHarnessData': []
        }

        # Create the actual config.
        config = {
            'initialCbsdRequestsWithDomainProxies':
            self.getEmptyCbsdRequestsWithDomainProxies(2),
            'initialCbsdRecords': [],
            'iterationData': [iteration_config],
            'sasTestHarnessConfigs': [],
            'domainProxyConfigs': [{
                'cert': getCertFilename('domain_proxy.cert'),
                'key': getCertFilename('domain_proxy.key')
            }, {
                'cert':
                getCertFilename('domain_proxy_1.cert'),
                'key':
                getCertFilename('domain_proxy_1.key')
            }]
        }
        writeConfig(filename, config)
Пример #28
0
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
import json
import logging
import os
from OpenSSL import SSL
from OpenSSL.crypto import load_certificate, FILETYPE_PEM

from request_handler import HTTPError
import security_testcase
from util import winnforum_testcase, configurable_testcase, writeConfig, \
  loadConfig, getCertificateFingerprint, getCertFilename
from request_handler import HTTPError

SAS_CERT = getCertFilename('sas.cert')
SAS_KEY = getCertFilename('sas.key')
SAS_TEST_HARNESS_URL = 'https://fake.sas.url.not.used/v1.2'


class SasToSasSecurityTestcase(security_testcase.SecurityTestCase):
    # Tests changing the SAS UUT state must explicitly call the SasReset().

    @winnforum_testcase
    def test_WINNF_FT_S_SSS_1(self):
        """New registration with TLS_RSA_WITH_AES_128_GCM_SHA256 cipher.

    Checks that SAS UUT response satisfy cipher security conditions.
    Checks that a SAS registration with this configuration succeed.
    """
        self.doSasTestCipher('AES128-GCM-SHA256',
  def generate_GPR_1_default_config(self, filename):
    """ Generates the WinnForum configuration for GPR.1. """

    # Load GWPZ Record
    gwpz_record_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'gwpz_record_0.json')))

    # Load devices info
    device_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_a.json')))
    # Moving device_1 to a location within 40 KMs of GWPZ zone
    device_1['installationParam']['latitude'] = 39.10448
    device_1['installationParam']['longitude'] = -99.7792

    device_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_b.json')))
    # Moving device_2 to a location outside 40 KMs of GWPZ zone
    device_2['installationParam']['latitude'] = 37.83075
    device_2['installationParam']['longitude'] = -107.65025

    device_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_c.json')))
    # Moving device_3 to a location inside GWPZ zone
    device_3['installationParam']['latitude'], \
    device_3['installationParam']['longitude'] = getRandomLatLongInPolygon(gwpz_record_1)

    device_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'device_d.json')))
    # Moving device_4 to a location outside 40 KMs of GWPZ zone
    device_4['installationParam']['latitude'] = 38.0934
    device_4['installationParam']['longitude'] = -106.91676

    # Load Grant requests
    grant_request_1 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))
    grant_request_2 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_1.json')))
    grant_request_3 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_2.json')))
    grant_request_4 = json.load(
      open(os.path.join('testcases', 'testdata', 'grant_0.json')))

    # device_b and device_d are Category B
    # Load Conditional Data
    self.assertEqual(device_2['cbsdCategory'], 'B')
    conditionals_device_2 = {
        'cbsdCategory': device_2['cbsdCategory'],
        'fccId': device_2['fccId'],
        'cbsdSerialNumber': device_2['cbsdSerialNumber'],
        'airInterface': device_2['airInterface'],
        'installationParam': device_2['installationParam'],
        'measCapability': device_2['measCapability']
    }

    self.assertEqual(device_4['cbsdCategory'], 'B')
    conditionals_device_4 = {
        'cbsdCategory': device_4['cbsdCategory'],
        'fccId': device_4['fccId'],
        'cbsdSerialNumber': device_4['cbsdSerialNumber'],
        'airInterface': device_4['airInterface'],
        'installationParam': device_4['installationParam'],
        'measCapability': device_4['measCapability']
    }

    # Remove conditionals from registration
    del device_2['cbsdCategory']
    del device_2['airInterface']
    del device_2['installationParam']
    del device_2['measCapability']
    del device_4['cbsdCategory']
    del device_4['airInterface']
    del device_4['installationParam']
    del device_4['measCapability']

    # Registration and grant records
    cbsd_records_domain_proxy_0 = {
        'registrationRequests': [device_1, device_2],
        'grantRequests': [grant_request_1, grant_request_2],
        'conditionalRegistrationData': [conditionals_device_2]
    }
    cbsd_records_domain_proxy_1 = {
        'registrationRequests': [device_3],
        'grantRequests': [grant_request_3],
        'conditionalRegistrationData': []
    }

    # Protected entity record
    protected_entities = {
        'gwpzRecords': [gwpz_record_1]
    }

    iteration_config = {
        'cbsdRequestsWithDomainProxies': [cbsd_records_domain_proxy_0,
                                          cbsd_records_domain_proxy_1],
        'cbsdRecords': [{
            'registrationRequest': device_4,
            'grantRequest': grant_request_4,
            'conditionalRegistrationData': conditionals_device_4,
            'clientCert': getCertFilename('device_d.cert'),
            'clientKey': getCertFilename('device_d.key')
        }],
        'protectedEntities': protected_entities,
        'dpaActivationList': [],
        'dpaDeactivationList': [],
        'sasTestHarnessData': []
    }

    # Create the actual config.
    config = {
        'initialCbsdRequestsWithDomainProxies': self.getEmptyCbsdRequestsWithDomainProxies(2),
        'initialCbsdRecords': [],
        'iterationData': [iteration_config],
        'sasTestHarnessConfigs': [],
        'domainProxyConfigs': [{
            'cert': getCertFilename('domain_proxy.cert'),
            'key': getCertFilename('domain_proxy.key')
        }, {
            'cert': getCertFilename('domain_proxy_1.cert'),
            'key': getCertFilename('domain_proxy_1.key')
        }]
    }
    writeConfig(filename, config)
    def generate_FAD_2_default_config(self, filename):
        """Generates the WinnForum configuration for FAD_2"""
        # Create the actual config for FAD_2

        # Load the esc sensor in SAS Test Harness
        esc_sensor = json.load(
            open(
                os.path.join('testcases', 'testdata',
                             'esc_sensor_record_0.json')))

        # Load the device_c1 with registration in SAS Test Harness
        device_c1 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_a.json')))

        # Get a latitude and longitude within 40 kms from ESC.
        latitude, longitude, _ = vincenty.GeodesicPoint(
            esc_sensor['installationParam']['latitude'],
            esc_sensor['installationParam']['longitude'], 0.1,
            30)  # distance of 0.1 km from ESC at 30 degrees

        # Load the device_c1 in the neighborhood area of the ESC sensor
        device_c1['installationParam']['latitude'] = latitude
        device_c1['installationParam']['longitude'] = longitude

        # Load grant request for device_c1
        grant_g1 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_g1['operationParam']['maxEirp'] = 20

        # Load one ppa in SAS Test Harness
        pal_record_0 = json.load(
            open(os.path.join('testcases', 'testdata', 'pal_record_0.json')))
        pal_low_frequency = 3550000000
        pal_high_frequency = 3560000000
        ppa_record_0 = json.load(
            open(os.path.join('testcases', 'testdata', 'ppa_record_0.json')))

        ppa_record_a, pal_records = makePpaAndPalRecordsConsistent(
            ppa_record_0, [pal_record_0], pal_low_frequency,
            pal_high_frequency, 'test_user_1')

        # Load device_c3 in SAS Test Harness
        device_c3 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_c.json')))

        # Load the device_c3 in the neighborhood area of the PPA
        device_c3['installationParam']['latitude'] = 38.821322
        device_c3['installationParam']['longitude'] = -97.280040

        # Load grant request for device_c3 in SAS Test Harness
        grant_g3 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_g3['operationParam']['maxEirp'] = 20

        # Update grant_g3 frequency to overlap with PPA zone frequency for C3 device
        grant_g3['operationParam']['operationFrequencyRange'] = {
            'lowFrequency': 3550000000,
            'highFrequency': 3555000000
        }

        # Load the device_c2 with registration to SAS UUT
        device_c2 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_b.json')))
        # Get a latitude and longitude within 40 kms from ESC.
        latitude, longitude, _ = vincenty.GeodesicPoint(
            esc_sensor['installationParam']['latitude'],
            esc_sensor['installationParam']['longitude'], 0.1,
            30)  # distance of 0.1 km from ESC at 30 degrees

        device_c2['installationParam']['latitude'] = latitude
        device_c2['installationParam']['longitude'] = longitude

        # Creating conditionals for C2 and C4.
        self.assertEqual(device_c2['cbsdCategory'], 'B')
        conditional_parameters_c2 = {
            'cbsdCategory': device_c2['cbsdCategory'],
            'fccId': device_c2['fccId'],
            'cbsdSerialNumber': device_c2['cbsdSerialNumber'],
            'airInterface': device_c2['airInterface'],
            'installationParam': device_c2['installationParam'],
            'measCapability': device_c2['measCapability']
        }
        del device_c2['cbsdCategory']
        del device_c2['airInterface']
        del device_c2['installationParam']

        # Load grant request for device_c2 to SAS UUT
        grant_g2 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_g2['operationParam']['maxEirp'] = 30

        # Load the device_c4 with registration to SAS UUT.
        device_c4 = json.load(
            open(os.path.join('testcases', 'testdata', 'device_d.json')))

        # Move device_c4 in the neighborhood area of the PPA
        device_c4['installationParam']['latitude'] = 38.8363
        device_c4['installationParam']['longitude'] = -97.2642
        device_c4['installationParam']['antennaBeamwidth'] = 0

        # Creating conditionals for Cat B devices.
        self.assertEqual(device_c4['cbsdCategory'], 'B')
        conditional_parameters_c4 = {
            'cbsdCategory': device_c4['cbsdCategory'],
            'fccId': device_c4['fccId'],
            'cbsdSerialNumber': device_c4['cbsdSerialNumber'],
            'airInterface': device_c4['airInterface'],
            'installationParam': device_c4['installationParam'],
            'measCapability': device_c4['measCapability']
        }
        del device_c4['cbsdCategory']
        del device_c4['airInterface']
        del device_c4['installationParam']

        # Load grant request for device_c4 to SAS UUT
        grant_g4 = json.load(
            open(os.path.join('testcases', 'testdata', 'grant_0.json')))
        grant_g4['operationParam']['maxEirp'] = 20

        #Update grant_g4 frequency to overlap with PPA zone frequency for C4 device
        grant_g4['operationParam']['operationFrequencyRange'] = {
            'lowFrequency': 3550000000,
            'highFrequency': 3555000000
        }

        conditionals = {
            'registrationData':
            [conditional_parameters_c2, conditional_parameters_c4]
        }

        cbsd_records = [device_c1, device_c3]
        grant_record_list = [[grant_g1], [grant_g3]]
        ppa_records = [ppa_record_a]

        # Creating CBSD reference IDs of valid format
        cbsd_reference_id1 = generateCbsdReferenceId('test_fcc_id_x',
                                                     'test_serial_number_x')
        cbsd_reference_id2 = generateCbsdReferenceId('test_fcc_id_y',
                                                     'test_serial_number_y')
        cbsd_reference_ids = [[cbsd_reference_id1, cbsd_reference_id2]]

        # SAS test harness configuration
        sas_harness_config = {
            'sasTestHarnessName': 'SAS-TH-1',
            'hostName': getFqdnLocalhost(),
            'port': getUnusedPort(),
            'serverCert': getCertFilename('sas.cert'),
            'serverKey': getCertFilename('sas.key'),
            'caCert': "certs/ca.cert"
        }
        # Generate FAD Records for each record type like cbsd,zone and esc_sensor
        cbsd_fad_records = generateCbsdRecords(cbsd_records, grant_record_list)
        ppa_fad_records = generatePpaRecords(ppa_records, cbsd_reference_ids)
        esc_fad_records = [esc_sensor]

        sas_harness_dump_records = {
            'cbsdRecords': cbsd_fad_records,
            'ppaRecords': ppa_fad_records,
            'escSensorRecords': esc_fad_records
        }
        config = {
            'registrationRequestC2': device_c2,
            'registrationRequestC4': device_c4,
            'conditionalRegistrationData': conditionals,
            'grantRequestG2': grant_g2,
            'grantRequestG4': grant_g4,
            'palRecords': pal_records,
            'sasTestHarnessConfig': sas_harness_config,
            'sasTestHarnessDumpRecords': sas_harness_dump_records
        }
        writeConfig(filename, config)