-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default user positive and negative test for deploying #4221
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
81 changes: 81 additions & 0 deletions
81
integration/tests/main/09-user-positive-installation.spec.js
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,81 @@ | ||
// Copyright 2022 the Kubeapps contributors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const { test, expect } = require("@playwright/test"); | ||
const { KubeappsLogin } = require("../utils/kubeapps-login"); | ||
const utils = require("../utils/util-functions"); | ||
|
||
test.describe("Limited user simple deployments", () => { | ||
test("Regular user can deploy and delete packages in its own namespace from global repo without secrets", async ({ | ||
page, | ||
}) => { | ||
test.setTimeout(120000); | ||
|
||
// Log in as admin to create a repo without password | ||
const k = new KubeappsLogin(page); | ||
await k.doLogin("kubeapps-operator@example.com", "password", process.env.ADMIN_TOKEN); | ||
|
||
// Change namespace using UI | ||
await page.click(".kubeapps-dropdown .kubeapps-nav-link"); | ||
await page.selectOption('select[name="namespaces"]', "kubeapps"); | ||
await page.click('cds-button:has-text("Change Context")'); | ||
|
||
// Go to repos page | ||
await page.click(".dropdown.kubeapps-menu button.kubeapps-nav-link"); | ||
await page.click('a.dropdown-menu-link:has-text("App Repositories")'); | ||
await page.waitForTimeout(3000); | ||
|
||
// Add new repo | ||
const repoName = utils.getRandomName("repo-test-09"); | ||
console.log(`Creating repository "${repoName}"`); | ||
await page.click('cds-button:has-text("Add App Repository")'); | ||
await page.type("input#kubeapps-repo-name", repoName); | ||
await page.type( | ||
"input#kubeapps-repo-url", | ||
"https://prometheus-community.github.io/helm-charts", | ||
); | ||
await page.click('cds-button:has-text("Install Repo")'); | ||
await page.waitForLoadState("networkidle"); | ||
|
||
// Log out admin and log in regular user | ||
await k.doLogout(); | ||
await k.doLogin("kubeapps-user@example.com", "password", process.env.VIEW_TOKEN); | ||
|
||
// Switch to user's namespace using UI | ||
await page.click(".kubeapps-dropdown .kubeapps-nav-link"); | ||
await page.selectOption('select[name="namespaces"]', "kubeapps-user-namespace"); | ||
await page.click('cds-button:has-text("Change Context")'); | ||
|
||
// Select package to deploy | ||
await page.click('a.nav-link:has-text("Catalog")'); | ||
await page.locator("input#search").type("alertmanager"); | ||
await page.waitForTimeout(3000); | ||
await page.click('a:has-text("alertmanager")'); | ||
await page.click('cds-button:has-text("Deploy") >> nth=0'); | ||
|
||
// Deploy package | ||
const releaseNameLocator = page.locator("#releaseName"); | ||
await releaseNameLocator.waitFor(); | ||
await expect(releaseNameLocator).toHaveText(""); | ||
const releaseName = utils.getRandomName("test-09-release"); | ||
console.log(`Creating release "${releaseName}"`); | ||
await releaseNameLocator.type(releaseName); | ||
await page.locator('cds-button:has-text("Deploy")').click(); | ||
|
||
// Check that package is deployed | ||
await page.waitForSelector("css=.application-status-pie-chart-number >> text=1"); | ||
await page.waitForSelector("css=.application-status-pie-chart-title >> text=Ready"); | ||
|
||
// Delete deployment | ||
await page.locator('cds-button:has-text("Delete")').click(); | ||
await page.locator('cds-modal-actions button:has-text("Delete")').click(); | ||
await page.waitForTimeout(10000); | ||
|
||
// Search for package deployed | ||
await page.click('a.nav-link:has-text("Applications")'); | ||
await page.locator("input#search").type("alertmanager"); | ||
await page.waitForTimeout(3000); | ||
const packageLocator = page.locator('a:has-text("alertmanager")'); | ||
await expect(packageLocator).toHaveCount(0); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I wasn't thinking that we needed a new test for this, but rather just updating the existing default deployment test to use the
kubeapps-user
... we know if it passes with that that it will have no issues to pass with a higher-privileged account. Adding redundant tests will just lengthen the test run, won't it? Or is there a reason you think we should test both with thekubeapps-user
as well as withkubeapps-operator
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new
09
test, repository is created by admin user and consumed by another user with less privileges. I don't think we are covering that in other tests? I mean, in03
test, admin does everything (add repo, deploy, etc.) and in test04
admin deploys todefault
namespace using an initial repo from Kubeapps installation.I think each test covers a slightly different scenario, it's a bit of the "how far do we want to get with e2e tests?" question I would say.
However, happy to remove any test if you think that is not needed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I hadn't realised it was adding a repo. I'm OK with having a separate test, but it's not clear to me why we'd add a repo as part of this test (given we already have a repo with charts we can use for this test, and have other tests that add repositories). Also, I'm not sure about adding a non-bitnami repo so that our CI is now dependent on the prometheus community helm charts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, though it might be worth checking with @antgamdia - looks like he added the deletion. I can only guess that the intent was to use the
default
namespace for the kubeapps user and so extra RBAC for other namespaces was removed, at the time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, though I can't 100% remember, the idea was just using the default namespace (perhaps because of the problems you mentioned about the test selecting the wrong context?), so I just deleted this extra RBAC (which was granting
edit
ClusterRole in thekubeapps-user-namespace
namespace@castelblanque Now the tests are handling better how to switch contexts, +1 to remove any deletion that might veil any errors on the current rbac dev file we're using.