-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): added integraton test and code review changes
Signed-off-by: Łukasz Dziedziak <lukidzi@gmail.com>
- Loading branch information
Showing
5 changed files
with
182 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package projectedsatoken_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
|
||
"github.com/kumahq/kuma/pkg/test" | ||
"github.com/kumahq/kuma/test/e2e/projectedsatoken" | ||
) | ||
|
||
func TestE2E(t *testing.T) { | ||
test.RunSpecs(t, "E2E Projected SAT") | ||
} | ||
|
||
var _ = Describe("Test Projected Service Account Token on Universal", projectedsatoken.ProjectedServiceAccountToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package projectedsatoken | ||
|
||
import ( | ||
"strings" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/kumahq/kuma/pkg/config/core" | ||
. "github.com/kumahq/kuma/test/framework" | ||
) | ||
|
||
func ProjectedServiceAccountToken() { | ||
var universal Cluster | ||
|
||
BeforeEach(func() { | ||
clusters, err := NewUniversalClusters([]string{Kuma1}, Silent) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
universal = clusters.GetCluster(Kuma1) | ||
Expect(NewClusterSetup(). | ||
Install(Kuma(core.Standalone, | ||
WithEnv("KUMA_DP_SERVER_AUTH_USE_TOKEN_PATH", "true"), | ||
)). | ||
Install(DemoClientUniversal("demo-client", "default")). | ||
Setup(universal)).To(Succeed()) | ||
}) | ||
|
||
E2EAfterEach(func() { | ||
Expect(universal.DismissCluster()).To(Succeed()) | ||
}) | ||
|
||
It("should connect to restarted control plane with new token without dp restart", func() { | ||
// given | ||
uniCluster := universal.(*UniversalCluster) | ||
kumaCP := universal.(*UniversalCluster).GetApp(AppModeCP) | ||
|
||
// then should have dataplane in control plane | ||
Eventually(func() bool { | ||
stdout, _, err := uniCluster.Exec("", "", "kuma-cp", "kumactl", "get", "dataplanes") | ||
if err != nil { | ||
return false | ||
} | ||
return strings.Contains(stdout, "demo-client") | ||
}, "60s", "1s").Should(BeTrue()) | ||
|
||
// when restart control-plane | ||
Expect(kumaCP.ReStart()).Should(Succeed()) | ||
|
||
// then should not have demo-client in dataplanes | ||
Eventually(func() bool { | ||
stdout, _, err := uniCluster.Exec("", "", "kuma-cp", "kumactl", "get", "dataplanes") | ||
if err != nil { | ||
return true | ||
} | ||
return strings.Contains(stdout, "demo-client") | ||
}, "60s", "1s").Should(BeFalse()) | ||
|
||
// when new token generated | ||
token, err := universal.GetKuma().GenerateDpToken("default", "demo-client") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
// and set token | ||
_, _, err = universal.Exec("", "", "demo-client", "printf", "\""+token+"\"", ">", "/kuma/token-demo-client") | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
// then there should be dataplane for demo-client | ||
Eventually(func() bool { | ||
stdout, _, err := uniCluster.Exec("", "", "kuma-cp", "kumactl", "get", "dataplanes") | ||
if err != nil { | ||
return false | ||
} | ||
return strings.Contains(stdout, "demo-client") | ||
}, "60s", "1s").Should(BeTrue()) | ||
}) | ||
} |