diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 9a291aa5c17596fd3df4739d5f3e55aa5d48f79e..4156413f80a407e8ae365755cfb4cbfe9cfafb49 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -411,8 +411,10 @@ def only_for?(project) def short_sha return unless token + # We want to show the first characters of the hash, so we need to bypass any fixed components of the token, + # such as CREATED_RUNNER_TOKEN_PREFIX or partition_id_prefix_in_16_bit_encode start_index = authenticated_user_registration_type? ? CREATED_RUNNER_TOKEN_PREFIX.length : 0 - token[start_index..start_index + RUNNER_SHORT_SHA_LENGTH] + token[start_index..start_index + RUNNER_SHORT_SHA_LENGTH].delete_prefix(partition_id_prefix_in_16_bit_encode) end def tag_list diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 4eaf37857bc8db3eaaff08a0b7660f0130cd0451..8567ed906d7634653f993a1683eb385110d3b435 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -1697,6 +1697,7 @@ def does_db_update let(:runner) { create(:ci_runner) } specify { expect(runner.token).not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) } + it { is_expected.not_to start_with('t1_') } it { is_expected.not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) } end @@ -1704,6 +1705,7 @@ def does_db_update let(:runner) { create(:ci_runner, registration_type: :authenticated_user) } specify { expect(runner.token).to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) } + it { is_expected.not_to start_with('t1_') } it { is_expected.not_to start_with(described_class::CREATED_RUNNER_TOKEN_PREFIX) } end end