コード例 #1
0
def test_registration_build_token(initialized_db, token_type, expected_exception):
    build_id = str(uuid.uuid4())
    job_id = "building/" +  build_id
    token = build_token(
        app.config["SERVER_HOSTNAME"],
        BUILD_JOB_REGISTRATION_TYPE,
        build_id,
        job_id,
        int(time.time()) + 360,
        instance_keys)

    if expected_exception is not None:
        with pytest.raises(InvalidBuildTokenException) as ibe:
            payload = verify_build_token(
                token,
                app.config["SERVER_HOSTNAME"],
                token_type,
                instance_keys,
            )
        assert ibe.match(expected_exception)
    else:
        payload = verify_build_token(
            token,
            app.config["SERVER_HOSTNAME"],
            token_type,
            instance_keys,
        )

        assert payload["aud"] == app.config["SERVER_HOSTNAME"]
        assert payload["sub"] == ANONYMOUS_SUB
        assert payload["iss"] == instance_keys.service_name
        assert payload["context"]["build_id"] == build_id
        assert payload["context"]["job_id"] == job_id
        assert payload["context"]["token_type"] == BUILD_JOB_REGISTRATION_TYPE
コード例 #2
0
ファイル: ephemeral.py プロジェクト: wjjmjh/quay
 def generate_build_token(self, token_type, build_id, job_id, expiration):
     return build_token(
         self._manager_hostname, token_type, build_id, job_id, expiration, self._instance_keys
     )