Allow authority to be specified in check-pr (#1473)

* fix interactive login in check-pr

* specify tenant domain in check-pr

* bug fix

* rename tenant to authority
This commit is contained in:
Cheick Keita
2022-02-02 16:06:42 -08:00
committed by GitHub
parent 809db31186
commit ee4dfe922f
2 changed files with 39 additions and 7 deletions

View File

@ -873,13 +873,17 @@ class Run(Command):
test_id: UUID, test_id: UUID,
*, *,
endpoint: Optional[str], endpoint: Optional[str],
authority: Optional[str] = None,
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
poll: bool = False, poll: bool = False,
stop_on_complete_check: bool = False, stop_on_complete_check: bool = False,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, client_id=client_id, client_secret=client_secret endpoint=endpoint,
client_id=client_id,
client_secret=client_secret,
authority=authority,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
result = tester.check_jobs( result = tester.check_jobs(
@ -895,9 +899,13 @@ class Run(Command):
endpoint: Optional[str], endpoint: Optional[str],
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
authority: Optional[str] = None,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, client_id=client_id, client_secret=client_secret endpoint=endpoint,
client_id=client_id,
client_secret=client_secret,
authority=authority,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
launch_result, repros = tester.launch_repro() launch_result, repros = tester.launch_repro()
@ -910,6 +918,7 @@ class Run(Command):
samples: Directory, samples: Directory,
*, *,
endpoint: Optional[str] = None, endpoint: Optional[str] = None,
authority: Optional[str] = None,
client_id: Optional[str] = None, client_id: Optional[str] = None,
client_secret: Optional[str] = None, client_secret: Optional[str] = None,
pool_size: int = 10, pool_size: int = 10,
@ -925,7 +934,10 @@ class Run(Command):
def try_setup(data: Any) -> None: def try_setup(data: Any) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, client_id=client_id, client_secret=client_secret endpoint=endpoint,
client_id=client_id,
client_secret=client_secret,
authority=authority,
) )
retry(try_setup, "trying to configure") retry(try_setup, "trying to configure")
@ -940,11 +952,15 @@ class Run(Command):
test_id: UUID, test_id: UUID,
*, *,
endpoint: Optional[str], endpoint: Optional[str],
authority: Optional[str],
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, client_id=client_id, client_secret=client_secret endpoint=endpoint,
client_id=client_id,
client_secret=client_secret,
authority=authority,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id)
tester.cleanup() tester.cleanup()
@ -954,11 +970,15 @@ class Run(Command):
test_id: UUID, test_id: UUID,
*, *,
endpoint: Optional[str], endpoint: Optional[str],
authority: Optional[str] = None,
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, client_id=client_id, client_secret=client_secret endpoint=endpoint,
client_id=client_id,
client_secret=client_secret,
authority=authority,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id)
tester.check_logs_for_errors() tester.check_logs_for_errors()
@ -968,6 +988,7 @@ class Run(Command):
samples: Directory, samples: Directory,
*, *,
endpoint: Optional[str] = None, endpoint: Optional[str] = None,
authority: Optional[str] = None,
client_id: Optional[str] = None, client_id: Optional[str] = None,
client_secret: Optional[str] = None, client_secret: Optional[str] = None,
pool_size: int = 15, pool_size: int = 15,
@ -985,6 +1006,7 @@ class Run(Command):
self.launch( self.launch(
samples, samples,
endpoint=endpoint, endpoint=endpoint,
authority=authority,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
pool_size=pool_size, pool_size=pool_size,
@ -997,6 +1019,7 @@ class Run(Command):
self.check_jobs( self.check_jobs(
test_id, test_id,
endpoint=endpoint, endpoint=endpoint,
authority=authority,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
poll=True, poll=True,
@ -1009,6 +1032,7 @@ class Run(Command):
self.check_repros( self.check_repros(
test_id, test_id,
endpoint=endpoint, endpoint=endpoint,
authority=authority,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
) )
@ -1018,6 +1042,7 @@ class Run(Command):
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority,
) )
except Exception as e: except Exception as e:
@ -1034,6 +1059,7 @@ class Run(Command):
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority,
) )
except Exception as e: except Exception as e:
self.logger.error("testing failed: %s", repr(e)) self.logger.error("testing failed: %s", repr(e))

View File

@ -167,6 +167,7 @@ class Deployer:
instance: str, instance: str,
region: str, region: str,
subscription_id: Optional[str], subscription_id: Optional[str],
authority: Optional[str],
skip_tests: bool, skip_tests: bool,
test_args: List[str], test_args: List[str],
repo: str, repo: str,
@ -182,8 +183,9 @@ class Deployer:
self.test_args = test_args or [] self.test_args = test_args or []
self.repo = repo self.repo = repo
self.unattended = unattended self.unattended = unattended
self.client_id = "" self.client_id: Optional[str] = None
self.client_secret = "" self.client_secret: Optional[str] = None
self.authority = authority
def merge(self) -> None: def merge(self) -> None:
if self.pr: if self.pr:
@ -272,6 +274,7 @@ class Deployer:
if self.unattended if self.unattended
else "" else ""
) )
authority_args = f"--authority {self.authority}" if self.authority else ""
commands = [ commands = [
( (
@ -286,6 +289,7 @@ class Deployer:
( (
f"{py} {test_dir}/{script} test {test_dir} " f"{py} {test_dir}/{script} test {test_dir} "
f"--region {self.region} --endpoint {endpoint} " f"--region {self.region} --endpoint {endpoint} "
f"{authority_args} "
f"{unattended_args} {test_args}" f"{unattended_args} {test_args}"
), ),
), ),
@ -361,6 +365,7 @@ def main() -> None:
parser.add_argument("--skip-cleanup-on-failure", action="store_true") parser.add_argument("--skip-cleanup-on-failure", action="store_true")
parser.add_argument("--merge-on-success", action="store_true") parser.add_argument("--merge-on-success", action="store_true")
parser.add_argument("--subscription_id") parser.add_argument("--subscription_id")
parser.add_argument("--authority", default=None)
parser.add_argument("--test_args", nargs=argparse.REMAINDER) parser.add_argument("--test_args", nargs=argparse.REMAINDER)
parser.add_argument("--unattended", action="store_true") parser.add_argument("--unattended", action="store_true")
args = parser.parse_args() args = parser.parse_args()
@ -378,6 +383,7 @@ def main() -> None:
test_args=args.test_args, test_args=args.test_args,
repo=args.repo, repo=args.repo,
unattended=args.unattended, unattended=args.unattended,
authority=args.authority,
) )
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
os.chdir(directory) os.chdir(directory)