Add unmanaged nodes integration tests (#2780)

* Add docker file to the runtime tools

* fixes

* bug fixes

* more bug fixes and added doc

* don;t overwrite the RUST_LOG env var

* integration test for unmanaged nodes

* add unamanged parameters to launch()

* add ing object_id

* more bug fixes

* bug fixes

* chmod on the linux files in docker

* format

* cleanup merge

* added test_unmanaged command

* cleanup

* use a single image for the docker compose
remove images after the test

* docs and formatting

* format

* format

* format and bug fixes

* using windows server

* fix linux container
make the base image a paramter on windows
use the windows server base image on  windows server

* format

* bug fix

* more fixes

* allow reboot

* more fixes

* added more logging around the service principal creation

* format

* more logging

* change restart policy

* fix multi tenant domain

* more fixes

* exit instead of reboot when running inside docker

* remove comment

* build fix

* try_exist instead of exist

* save the docker logs

* bug_fix

* adding timeout

* fix timeout logic

* adding a build profile

* make all agent depend on the first one

* remove profile

* another fix

* restart agent 1

* Update docs/unmnaged-nodes.md

Co-authored-by: Teo Voinea <58236992+tevoinea@users.noreply.github.com>

---------

Co-authored-by: Teo Voinea <58236992+tevoinea@users.noreply.github.com>
This commit is contained in:
Cheick Keita
2023-02-08 11:07:19 -08:00
committed by GitHub
parent f93c75556d
commit d732028201
9 changed files with 404 additions and 51 deletions

View File

@ -1281,7 +1281,7 @@ class Pool(Endpoint):
client_secret="<client_secret>",
resource=self.onefuzz._backend.config.endpoint,
tenant=urlparse(self.onefuzz._backend.config.authority).path.strip("/"),
multi_tenant_domain=self.onefuzz._backend.config.tenant_domain,
multi_tenant_domain=self.onefuzz._backend.config.get_multi_tenant_domain(),
)
return pool.config

View File

@ -98,6 +98,12 @@ class BackendConfig(BaseModel):
features: Set[str] = Field(default_factory=set)
tenant_domain: str
def get_multi_tenant_domain(self) -> Optional[str]:
if "https://login.microsoftonline.com/common" in self.authority:
return self.tenant_domain
else:
return None
class Backend:
def __init__(
@ -182,10 +188,11 @@ class Backend:
if not self.config.endpoint:
raise Exception("endpoint not configured")
if "https://login.microsoftonline.com/common" in self.config.authority:
multi_tenant_domain = self.config.get_multi_tenant_domain()
if multi_tenant_domain is not None:
endpoint = urlparse(self.config.endpoint).netloc.split(".")[0]
scopes = [
f"api://{self.config.tenant_domain}/{endpoint}/.default",
f"api://{multi_tenant_domain}/{endpoint}/.default",
]
else:
netloc = urlparse(self.config.endpoint).netloc