Beispiel #1
0
    def testEndToEnd(self):
        # extract ids from a simulated data repo with the same config
        repo = datarepo.SimulatedDataRepository()
        dataset = repo.getDatasets()[0]
        datasetId = dataset.getId()
        variantSet = dataset.getVariantSets()[0]
        variantSetId = variantSet.getId()
        readGroupSet = dataset.getReadGroupSets()[0]
        readGroupId = readGroupSet.getReadGroups()[0].getId()
        referenceSet = repo.getReferenceSets()[0]
        referenceSetId = referenceSet.getId()
        referenceId = referenceSet.getReferences()[0].getId()
        variantAnnotationSetId = \
            variantSet.getVariantAnnotationSets()[0].getId()

        self.simulatedDatasetId = datasetId
        self.simulatedVariantSetId = variantSetId
        self.simulatedReadGroupId = readGroupId
        self.simulatedReferenceSetId = referenceSetId
        self.simulatedReferenceId = referenceId
        self.simulatedVariantAnnotationSetId = variantAnnotationSetId
        self.client = client.ClientForTesting(self.server.getUrl())
        self.runVariantsRequest()
        self.assertLogsWritten()
        self.runReadsRequest()
        self.runReferencesRequest()
        self.runVariantSetsRequestDatasetTwo()
        self.runVariantAnnotationsRequest()
        self.runGetVariantAnnotationSetsRequest()
        self.client.cleanup()
Beispiel #2
0
 def setUpClass(cls):
     cls.numReferences = 25
     cls.backend = backend.Backend(datarepo.SimulatedDataRepository(
         randomSeed=100, numDatasets=0,
         numReferenceSets=1,
         numReferencesPerReferenceSet=cls.numReferences))
     cls.dataRepo = cls.backend.getDataRepository()
Beispiel #3
0
 def setUpClass(cls):
     cls.backend = backend.Backend(datarepo.SimulatedDataRepository(
         randomSeed=100, numDatasets=3,
         numVariantSets=3, numCalls=3, variantDensity=0.5,
         numReferenceSets=3, numReferencesPerReferenceSet=3,
         numReadGroupSets=3, numReadGroupsPerReadGroupSet=3,
         numAlignments=3))
     cls.dataRepo = cls.backend.getDataRepository()
 def setUp(self):
     self.request = protocol.SearchReadsRequest()
     self.backend = backend.Backend(
         datarepo.SimulatedDataRepository(numAlignments=0))
     dataRepo = self.backend.getDataRepository()
     referenceSet = dataRepo.getReferenceSetByIndex(0)
     reference = referenceSet.getReferenceByIndex(0)
     self.request.reference_id = reference.getId()
     self.dataset = dataRepo.getDatasets()[0]
     self.readGroupSet = self.dataset.getReadGroupSets()[0]
Beispiel #5
0
    def otherSetup(cls):
        # extract ids from a simulated data repo with the same config
        repo = datarepo.SimulatedDataRepository()
        dataset = repo.getDatasets()[0]
        variantSet = dataset.getVariantSets()[0]
        variantSetId = variantSet.getId()

        cls.simulatedVariantSetId = variantSetId
        requests.packages.urllib3.disable_warnings()
        cls.opServer = server.OidcOpServerForTesting()
        cls.opServer.start()
Beispiel #6
0
def configure(configFile=None, baseConfig="ProductionConfig",
              port=8000, extraConfig={}):
    """
    TODO Document this critical function! What does it do? What does
    it assume?
    """
    configStr = 'ga4gh.serverconfig:{0}'.format(baseConfig)
    app.config.from_object(configStr)
    if os.environ.get('GA4GH_CONFIGURATION') is not None:
        app.config.from_envvar('GA4GH_CONFIGURATION')
    if configFile is not None:
        app.config.from_pyfile(configFile)
    app.config.update(extraConfig.items())
    # Setup file handle cache max size
    datamodel.fileHandleCache.setMaxCacheSize(
        app.config["FILE_HANDLE_CACHE_MAX_SIZE"])
    # Setup CORS
    cors.CORS(app, allow_headers='Content-Type')
    app.serverStatus = ServerStatus()
    # Allocate the backend
    # We use URLs to specify the backend. Currently we have file:// URLs (or
    # URLs with no scheme) for the FileSystemBackend, and special empty:// and
    # simulated:// URLs for empty or simulated data sources.
    dataSource = urlparse.urlparse(app.config["DATA_SOURCE"], "file")

    if dataSource.scheme == "simulated":
        # Ignore the query string
        randomSeed = app.config["SIMULATED_BACKEND_RANDOM_SEED"]
        numCalls = app.config["SIMULATED_BACKEND_NUM_CALLS"]
        variantDensity = app.config["SIMULATED_BACKEND_VARIANT_DENSITY"]
        numVariantSets = app.config["SIMULATED_BACKEND_NUM_VARIANT_SETS"]
        numReferenceSets = app.config[
            "SIMULATED_BACKEND_NUM_REFERENCE_SETS"]
        numReferencesPerReferenceSet = app.config[
            "SIMULATED_BACKEND_NUM_REFERENCES_PER_REFERENCE_SET"]
        numAlignmentsPerReadGroup = app.config[
            "SIMULATED_BACKEND_NUM_ALIGNMENTS_PER_READ_GROUP"]
        dataRepository = datarepo.SimulatedDataRepository(
            randomSeed=randomSeed, numCalls=numCalls,
            variantDensity=variantDensity, numVariantSets=numVariantSets,
            numReferenceSets=numReferenceSets,
            numReferencesPerReferenceSet=numReferencesPerReferenceSet,
            numAlignments=numAlignmentsPerReadGroup)
    elif dataSource.scheme == "empty":
        dataRepository = datarepo.EmptyDataRepository()
    elif dataSource.scheme == "file":
        dataRepository = datarepo.FileSystemDataRepository(os.path.join(
            dataSource.netloc, dataSource.path))
        dataRepository.checkConsistency()
    else:
        raise exceptions.ConfigurationException(
            "Unsupported data source scheme: " + dataSource.scheme)
    theBackend = backend.Backend(dataRepository)
    theBackend.setRequestValidation(app.config["REQUEST_VALIDATION"])
    theBackend.setResponseValidation(app.config["RESPONSE_VALIDATION"])
    theBackend.setDefaultPageSize(app.config["DEFAULT_PAGE_SIZE"])
    theBackend.setMaxResponseLength(app.config["MAX_RESPONSE_LENGTH"])
    app.backend = theBackend
    app.secret_key = os.urandom(SECRET_KEY_LENGTH)
    app.oidcClient = None
    app.tokenMap = None
    app.myPort = port
    if "OIDC_PROVIDER" in app.config:
        # The oic client. If we're testing, we don't want to verify
        # SSL certificates
        app.oidcClient = oic.oic.Client(
            verify_ssl=('TESTING' not in app.config))
        app.tokenMap = {}
        try:
            app.oidcClient.provider_config(app.config['OIDC_PROVIDER'])
        except requests.exceptions.ConnectionError:
            configResponse = message.ProviderConfigurationResponse(
                issuer=app.config['OIDC_PROVIDER'],
                authorization_endpoint=app.config['OIDC_AUTHZ_ENDPOINT'],
                token_endpoint=app.config['OIDC_TOKEN_ENDPOINT'],
                revocation_endpoint=app.config['OIDC_TOKEN_REV_ENDPOINT'])
            app.oidcClient.handle_provider_config(configResponse,
                                                  app.config['OIDC_PROVIDER'])

        # The redirect URI comes from the configuration.
        # If we are testing, then we allow the automatic creation of a
        # redirect uri if none is configured
        redirectUri = app.config.get('OIDC_REDIRECT_URI')
        if redirectUri is None and 'TESTING' in app.config:
            redirectUri = 'https://{0}:{1}/oauth2callback'.format(
                socket.gethostname(), app.myPort)
        app.oidcClient.redirect_uris = [redirectUri]
        if redirectUri is []:
            raise exceptions.ConfigurationException(
                'OIDC configuration requires a redirect uri')

        # We only support dynamic registration while testing.
        if ('registration_endpoint' in app.oidcClient.provider_info and
           'TESTING' in app.config):
            app.oidcClient.register(
                app.oidcClient.provider_info["registration_endpoint"],
                redirect_uris=[redirectUri])
        else:
            response = message.RegistrationResponse(
                client_id=app.config['OIDC_CLIENT_ID'],
                client_secret=app.config['OIDC_CLIENT_SECRET'],
                redirect_uris=[redirectUri],
                verify_ssl=False)
            app.oidcClient.store_registration_info(response)
 def setUp(self):
     self.request = protocol.SearchVariantsRequest()
     self.backend = backend.Backend(datarepo.SimulatedDataRepository())
     self.dataset = self.backend.getDataRepository().getDatasets()[0]