LCOV - code coverage report
Current view: top level - httpd - GitOverHttpModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 8 9 88.9 %
Date: 2022-11-19 15:00:39 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2009 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.httpd;
      16             : 
      17             : import static com.google.gerrit.httpd.GitOverHttpServlet.URL_REGEX;
      18             : 
      19             : import com.google.gerrit.entities.CoreDownloadSchemes;
      20             : import com.google.gerrit.server.config.AuthConfig;
      21             : import com.google.gerrit.server.config.DownloadConfig;
      22             : import com.google.inject.Inject;
      23             : import com.google.inject.servlet.ServletModule;
      24             : 
      25             : /** Configures Git access over HTTP with authentication. */
      26             : public class GitOverHttpModule extends ServletModule {
      27             :   private final AuthConfig authConfig;
      28             :   private final DownloadConfig downloadConfig;
      29             : 
      30             :   @Inject
      31          99 :   GitOverHttpModule(AuthConfig authConfig, DownloadConfig downloadConfig) {
      32          99 :     this.authConfig = authConfig;
      33          99 :     this.downloadConfig = downloadConfig;
      34          99 :   }
      35             : 
      36             :   @Override
      37             :   protected void configureServlets() {
      38          99 :     if (downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.ANON_HTTP)
      39           0 :         || downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.HTTP)) {
      40          99 :       filterRegex(URL_REGEX).through(GerritAuthModule.retreiveAuthFilterFromConfig(authConfig));
      41          99 :       serveRegex(URL_REGEX).with(GitOverHttpServlet.class);
      42             :     }
      43          99 :   }
      44             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750