github.com/kyma-project/kyma-environment-broker@v0.0.1/testing/e2e/skr/skr-test/oidc/index.js (about) 1 const {expect} = require('chai'); 2 const { 3 updateSKR, 4 ensureValidShootOIDCConfig, 5 ensureValidOIDCConfigInCustomerFacingKubeconfig, 6 } = require('../../kyma-environment-broker'); 7 const { 8 ensureKymaAdminBindingExistsForUser, 9 ensureKymaAdminBindingDoesNotExistsForUser, 10 } = require('../../utils'); 11 const {keb, kcp, gardener} = require('../helpers'); 12 13 const updateTimeout = 1000 * 60 * 20; // 20m 14 15 function oidcE2ETest(getShootOptionsFunc, getShootInfoFunc) { 16 describe('OIDC Test', function() { 17 let shoot = undefined; 18 let options = undefined; 19 let givenOidcConfig = undefined; 20 21 before('Get provisioned Shoot Info', async function() { 22 shoot = getShootInfoFunc(); 23 options = getShootOptionsFunc(); 24 expect(shoot).to.not.be.undefined; 25 expect(options).to.not.be.undefined; 26 givenOidcConfig = shoot.oidcConfig; 27 }); 28 29 it('Assure initial OIDC config is applied on shoot cluster', async function() { 30 ensureValidShootOIDCConfig(shoot, givenOidcConfig); 31 }); 32 33 it('Assure initial OIDC config is part of kubeconfig', async function() { 34 await ensureValidOIDCConfigInCustomerFacingKubeconfig(keb, options.instanceID, givenOidcConfig); 35 }); 36 37 it('Assure initial cluster admin', async function() { 38 await ensureKymaAdminBindingExistsForUser(options.kebUserId); // default user id 39 }); 40 41 it('Update SKR service instance with OIDC config', async function() { 42 this.timeout(updateTimeout); 43 const customParams = { 44 oidc: options.oidc1, 45 }; 46 const skr = await updateSKR(keb, 47 kcp, 48 gardener, 49 options.instanceID, 50 shoot.name, 51 customParams, 52 updateTimeout, 53 null, 54 false); 55 shoot = skr.shoot; 56 }); 57 58 it('Should get Runtime Status after updating OIDC config', async function() { 59 try { 60 const runtimeStatus = await kcp.getRuntimeStatusOperations(options.instanceID); 61 console.log(`\nRuntime status: ${runtimeStatus}`); 62 await kcp.reconcileInformationLog(runtimeStatus); 63 } catch (e) { 64 console.log(`before hook failed: ${e.toString()}`); 65 } 66 }); 67 68 it('Assure updated OIDC config is applied on shoot cluster', async function() { 69 ensureValidShootOIDCConfig(shoot, options.oidc1); 70 }); 71 72 it('Assure updated OIDC config is part of kubeconfig', async function() { 73 await ensureValidOIDCConfigInCustomerFacingKubeconfig(keb, options.instanceID, options.oidc1); 74 }); 75 76 it('Assure cluster admin is preserved', async function() { 77 await ensureKymaAdminBindingExistsForUser(options.kebUserId); 78 }); 79 80 it('Update SKR service instance with new admins', async function() { 81 this.timeout(updateTimeout); 82 const customParams = { 83 administrators: options.administrators1, 84 }; 85 const skr = await updateSKR(keb, 86 kcp, 87 gardener, 88 options.instanceID, 89 shoot.name, 90 customParams, 91 updateTimeout, 92 null, 93 false); 94 95 shoot = skr.shoot; 96 }); 97 98 it('Should get Runtime Status after updating admins', async function() { 99 const runtimeStatus = await kcp.getRuntimeStatusOperations(options.instanceID); 100 console.log(`\nRuntime status: ${runtimeStatus}`); 101 await kcp.reconcileInformationLog(runtimeStatus); 102 }); 103 104 it('Assure only new cluster admins are configured', async function() { 105 await ensureKymaAdminBindingExistsForUser(options.administrators1[0]); 106 await ensureKymaAdminBindingExistsForUser(options.administrators1[1]); 107 await ensureKymaAdminBindingDoesNotExistsForUser(options.kebUserId); 108 }); 109 }); 110 } 111 112 module.exports = { 113 oidcE2ETest, 114 };