Commit 12d262c2 authored by Thong Kuah's avatar Thong Kuah

Merge branch '55362-refresh-blank-service-account-token' into 'master'

Refresh service_account_token for kubernetes_namespaces

See merge request gitlab-org/gitlab-ce!29657
parents 2dea03bf ee28255b
---
title: Refresh service_account_token for kubernetes_namespaces
merge_request: 29657
author:
type: fixed
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
deployment_cluster.present? && deployment_cluster.present? &&
deployment_cluster.managed? && deployment_cluster.managed? &&
!deployment_cluster.project_type? && !deployment_cluster.project_type? &&
kubernetes_namespace.new_record? (kubernetes_namespace.new_record? || kubernetes_namespace.service_account_token.blank?)
end end
def complete! def complete!
......
...@@ -16,5 +16,9 @@ FactoryBot.define do ...@@ -16,5 +16,9 @@ FactoryBot.define do
trait :with_token do trait :with_token do
service_account_token { FFaker::Lorem.characters(10) } service_account_token { FFaker::Lorem.characters(10) }
end end
trait :without_token do
service_account_token nil
end
end end
end end
...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do ...@@ -35,9 +35,15 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end end
context 'and a namespace is already created for this project' do context 'and a namespace is already created for this project' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster, project: build.project) } let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token, cluster: cluster, project: build.project) }
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
context 'and the service_account_token is blank' do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :without_token, cluster: cluster, project: build.project) }
it { is_expected.to be_truthy }
end
end end
context 'and cluster is project type' do context 'and cluster is project type' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment