Skip to content

Commit

Permalink
ServiceAccounts Details Page
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-logro authored and tekton-robot committed Jan 14, 2020
1 parent d6fd222 commit c76edc0
Show file tree
Hide file tree
Showing 18 changed files with 938 additions and 15 deletions.
6 changes: 6 additions & 0 deletions packages/utils/src/utils/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export const paths = {
serviceAccounts: {
all() {
return '/serviceaccounts';
},
byNamespace() {
return byNamespace({ path: '/serviceaccounts' });
},
byName() {
return byNamespace({ path: '/serviceaccounts/:serviceAccountName' });
}
},
taskRuns: {
Expand Down
24 changes: 23 additions & 1 deletion packages/utils/src/utils/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const namespace = 'fake_namespace';
const pipelineName = 'fake_pipelineName';
const pipelineResourceName = 'fake_pipelineResourceName';
const pipelineRunName = 'fake_pipelineRunName';
const serviceAccountName = 'fake_serviceAccountName';
const taskName = 'fake_taskName';
const taskRunName = 'fake_taskRunName';

Expand Down Expand Up @@ -149,7 +150,28 @@ describe('secrets', () => {
expect(urls.secrets.all()).toEqual(generatePath(paths.secrets.all()));
});
});

describe('serviceAccounts', () => {
it('all', () => {
expect(urls.serviceAccounts.all()).toEqual(
generatePath(paths.serviceAccounts.all())
);
});
it('byNamespace', () => {
expect(urls.serviceAccounts.byNamespace({ namespace })).toEqual(
generatePath(paths.serviceAccounts.byNamespace(), { namespace })
);
});
it('byName', () => {
expect(
urls.serviceAccounts.byName({ namespace, serviceAccountName })
).toEqual(
generatePath(paths.serviceAccounts.byName(), {
namespace,
serviceAccountName
})
);
});
});
describe('taskRuns', () => {
it('all', () => {
expect(urls.taskRuns.all()).toEqual(generatePath(paths.taskRuns.all()));
Expand Down
3 changes: 2 additions & 1 deletion src/actions/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export function fetchSecrets({ namespace } = {}) {
name: secret.metadata.name,
namespace: secret.metadata.namespace,
annotations: secret.metadata.annotations,
type: secret.type
type: secret.type,
username: secret.data.username
};
secretsFormatted.push(object);
});
Expand Down
6 changes: 4 additions & 2 deletions src/actions/secrets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ const dataFormatted = [
name: 'default-token-kbn7j',
annotations: undefined,
namespace: 'default',
type: 'userpass'
type: 'userpass',
username: '[email protected]'
},
{
name: 'another-token-kbn7j',
annotations: undefined,
namespace: 'default',
type: 'userpass'
type: 'userpass',
username: '[email protected]'
}
];
const postData = {
Expand Down
14 changes: 12 additions & 2 deletions src/actions/serviceAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { getServiceAccounts } from '../api';
import { fetchNamespacedCollection } from './actionCreators';
import { getServiceAccount, getServiceAccounts } from '../api';
import {
fetchNamespacedCollection,
fetchNamespacedResource
} from './actionCreators';

export function fetchServiceAccount({ name, namespace }) {
return fetchNamespacedResource('ServiceAccount', getServiceAccount, {
name,
namespace
});
}

export function fetchServiceAccounts({ namespace } = {}) {
return fetchNamespacedCollection('ServiceAccount', getServiceAccounts, {
Expand Down
14 changes: 13 additions & 1 deletion src/actions/serviceAccounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ limitations under the License.

import * as API from '../api';
import * as creators from './actionCreators';
import { fetchServiceAccounts } from './serviceAccounts';
import { fetchServiceAccount, fetchServiceAccounts } from './serviceAccounts';

it('fetchServiceAccounts', async () => {
jest.spyOn(creators, 'fetchNamespacedCollection');
Expand All @@ -26,6 +26,18 @@ it('fetchServiceAccounts', async () => {
);
});

it('fetchServiceAccount', async () => {
jest.spyOn(creators, 'fetchNamespacedResource');
const name = 'service-account1';
const namespace = 'namespace';
fetchServiceAccount({ name, namespace });
expect(creators.fetchNamespacedResource).toHaveBeenCalledWith(
'ServiceAccount',
API.getServiceAccount,
{ name, namespace }
);
});

it('fetchServiceAccounts no namespace', async () => {
jest.spyOn(creators, 'fetchNamespacedCollection');
fetchServiceAccounts();
Expand Down
11 changes: 11 additions & 0 deletions src/containers/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
Pipelines,
ResourceList,
Secrets,
ServiceAccount,
ServiceAccounts,
SideNav,
TaskRun,
Expand Down Expand Up @@ -190,11 +191,21 @@ export /* istanbul ignore next */ class App extends Component {
component={ImportResources}
/>
<Route path={paths.secrets.all()} exact component={Secrets} />
<Route
path={paths.serviceAccounts.byName()}
exact
component={ServiceAccount}
/>
<Route
path={paths.serviceAccounts.all()}
exact
component={ServiceAccounts}
/>
<Route
path={paths.serviceAccounts.byNamespace()}
exact
component={ServiceAccounts}
/>
<Route
path={paths.eventListeners.all()}
exact
Expand Down
Loading

0 comments on commit c76edc0

Please sign in to comment.