Skip to content

public-key-creation #42

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cypress/e2e/gui/allButProject.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../gui/profile/createAccessToken.cy'
import './admin/broadcastMessage.cy'
// The below test destroys the user session. The next one recreates it.
import './admin/impersonateUser.cy.js'
import './profile/deploykeyCreation.cy'
import './group/createGroup.cy'
import './group/createGroupLabel.cy'
import './group/removeGroup.cy.js'
Expand All @@ -13,7 +14,9 @@ import './profile/setStatus.cy.js'
import './snippets/createSnippet.cy.js'
import './authentication/loginAsNonDefaultUser.cy'


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por qual motivo você adicionou essa nova linha em branco? Favor removê-la.

// Teardown - Delete access token(s)
import './profile/deleteAccessTokens.cy'
// Leave the logout test to the end since it destroys the user session
import './authentication/logout.cy'

22 changes: 22 additions & 0 deletions cypress/e2e/gui/profile/deploykeyCreation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('Deploy Key Creation', () => {
Copy link
Owner

@wlsf82 wlsf82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O nome do arquivo deveria seguir a convenção camelCase, ou seja, em vez de deploykeyCreation.cy.js, devia ser deployKeyCreation.cy.js.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Além disso, visto que o teste é do domínio admin, o mesmo deveria estar na pasta cypress/e2e/gui/admin/

beforeEach(() => cy.sessionLogin())

it('creates an key ', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('creates an key ', () => {
it('CRUDS a deploy key successfully', () => {

Copy link
Owner

@wlsf82 wlsf82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Além disso, visto que isso é um teste de CRUD, faltou o update.

Ao testar o update, verificar mensagem de sucesso, além de verificar que o título foi atualizado.

/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover comentários desnecessários.

* início
* 1 -Acesssa a sessionLogin
* 2 - Uso dois comandos customizados que são eles:
* gui_deployKeyCreationName() , para gerar um nome aleatório para a key
* gui_deployKeyCreation() , contém a key publica na variável "const publicKey" com valor da key gerada antes
* 3 - verifica o número de key(s), se é igual a (1) assert, caso seja,
* passa para o próximo step que é clique btn "remove"
* 4 - Clique no BTN "remove"
* 5 - Verifica o se número de Keys é igual (0) assert
* fim
*/
cy.gui_deployKeyCreationName()
cy.gui_deployKeyCreation()
cy.gui_deleteKey()
})
})

49 changes: 49 additions & 0 deletions cypress/fixtures/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-----BEGIN OPENSSH PRIVATE KEY-----
Copy link
Owner

@wlsf82 wlsf82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deletar fixtures não utilizadas.
A propósito, private e public keys nunca deveriam ser versionadas.

b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAgEAqlL+eBorYyJKxGgymkjhpdG3oN2W0DNUlE5xkeHvvivYZK5grl+p
xlnAkaKJfTqGEkvtzOEoG0RHI3405UhSWcNDU1+UmHBfFi1Ag6yrKW9J1OjFPOMYEM3gWa
hNzj5g+jw96wNLSL0z4we0vdOnlkBJ3QSPUb9US+288JyejfmLNn9RfERkKBCQSNGq3J5y
gc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K9qMmcAyxhMJm6fOyVuc0I9TF6UN8XhltpiKhkOeahNglTyJXVfaAN0AADwHshFfhoZp
1rtv9hTuZrVHvxLRb4LbKMDh+hZYk91D4c8hqddHkaW1iMOuB+rURSLnlZtb0XgA286FfJ
0GnRTBIvA7g+JyYw9QAAAQEA3ZWdlKHD/OHW3jND9VcuZ8ucVIAUq8RNmEwDkhP5YpRW8z
TWwGhm4SG6GwDoxY8bupeILgPaDIQRuwGhjRRMhzUUiPSSR3o35X0LUEOk+jg1tJnDoJ1R
GpSBmZW1EXtBZpH8tIjUH3LYrrH3ioImntgZ6O90Dx96/VhvZtTCUbP3DxPEoB6kiuQKLV
rZ7mYdczF0EltH3B8QnJWMVu9HdkKtfSvBGcJtNATCZQNb49cmDcqs+lnP9LAY9l/g4WfM
HUaIxCqMCxNIVCMWgPEldTvGoueKgQcVPEkVveqFCGhgKsRgEfztdJd01FL/3/TYBMD+vg
M3DGYDmIL5yC9AywAAAQEAxMc6XXtNJxA2ypX6tqwz5U0bT9PWBaL4lapWSQmALf7HQ2HI
mtIaBB2Pllh277zQxv99uJ/47a8e+ANc70WHBHUHzmcCspuPIzS2e6UymfpdIBsYz4U7jZ
9z+dqX47AqGvcLf/SZ3IsjyhUASmjYeYMrcVY1OE/iM5UPn7Z9JLBly+3P8hFODDsykNTX
h/GZtFmCm+u49RnaiZSB8aKPIJ9eBIt8Gjjd+01+wK51Ug3WBRm8nVUNY/zQrhi+TbDo78
aQkkx7wilVRT9K3hfn1PW0HBVCn7MZpDwOQ9hJCy4sRSo6NzdptPtU7/RbFPjc92qx1SG1
4O3qVqr4ha/5jQAAABVzZXUtZW1haWxAZXhhbXBsZS5jb20BAgME
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions cypress/fixtures/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqUv54GitjIkrEaDKaSOGl0beg3ZbQM1SUTnGR4e++K9hkrmCuX6nGWcCRool9OoYSS+3M4SgbREcjfjTlSFJZw0NTX5SYcF8WLUCDrKspb0nU6MU84xgQzeBZqE3OPmD6PD3rA0tIvTPjB7S906eWQEndBI9Rv1RL7bzwnJ6N+Ys2f1F8RGQoEJBI0arcnnKBxN091KSg+vZOARDdcOjAFDdpF/1acbJl8qvG/n9s6ahDGp2bHj4+OUw7o/CXPvudKEdZiooTdln63RCRBgNEAOwso32KllBIyUPP1YLfdEwEKcbJVs2iP/IRLx0mgkZaMWshyv+zaIlKvJnZWE7ag6uZg2WdtuZkCooqTyqR3iemMY7kfTI2cyGNzuQr1fd/2RtzmdtuZi7OCfbRlctH7Ez+UlrTiCv9Kz6ZCVBWSFWJKYxor/mYzP7NaP6kSfvgL1lyIjbH+OrZ0zPwlJFOQY6EtKLBqNamSxuhuPFJ9QHaTD7GRQmjbPh4ABn/bLN/M+k14awMCZK5N+6sQbNEKD6PxfWcH/7Al6JQoxRHSLwxpZ64aZ+0SJ5lPExr0wP2/tAkzrWaPLxJ/rkcfA2zULCRqXlkjeLNs5EoAMq7I3zbrKOCdCoQpkWolitdhsijgezYAdxv7t4syewoM0f8xyD/F4SQjO5BJQ7n+dEizw== [email protected]
20 changes: 20 additions & 0 deletions cypress/support/commands/gui_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,23 @@ Cypress.Commands.add('assertStatus', statusText => {
.should('contain', statusText)
cy.get('.qa-user-avatar').click()
})
// CRUD
Copy link
Owner

@wlsf82 wlsf82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remover comentário e adicionar uma linha em branco para seguir a consistência.

Cypress.Commands.add('gui_deployKeyCreationName', (name = faker.string.uuid()) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Os comandos gui_deployKeyCreationName e gui_deployKeyCreation poderiam ser unificados em um só.
Ou melhor, que tal deixar a lógica direto no arquivo de teste?

cy.visit('http://localhost/admin/deploy_keys/new')
Copy link
Owner

@wlsf82 wlsf82 Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A baseUrl já está definida no arquivo cypress.config.js, e portanto, não precisa estar aqui.

cy.get('#deploy_key_title').type(name)
})

Cypress.Commands.add('gui_deployKeyCreation',() => {
const publicKey = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF55ZxNcdW524Ob/y6kFkYu92DjTi2bqLkz37AFgFpZ+ [email protected]'
cy.get('#deploy_key_key').type(publicKey)
cy.get('.btn-success').click()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.get('.btn-success').click()
cy.get('input[type="submit"][value="Create"]').click()

Copy link
Owner

@wlsf82 wlsf82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Após a criação da key, gostaria de uma verificação de que a mesma foi criada. Algo como o seguinte:

cy.contains(‘.deploy-keys-list table tbody tr’, title).should(‘be.visible’)


})
Cypress.Commands.add('gui_deleteKey', () => {
cy.get('.page-title')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que tal assim?

cy.contains(‘h3’, ‘Public deploy keys (1)’).should(‘be.visible’)

.should('contain', '1')
cy.get('.btn-remove').click()
cy.get('.page-title')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui também

cy.contains(‘h3’, ‘Public deploy keys (0)’).should(‘be.visible’)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Além disso, seria interessante verificar que a tabela de keys não existe mais.
Algo assim:

Definir um cy.intercept().as('alias') pro POST que remove a deploy key antes do clique no botão que à remove, em conjunto com cy.wait(‘@alias’) depois do clique no botão. E então um cy.contains(‘.deploy-keys-list table tbody tr’, title).should(‘not exist’)

.should('contain', '0')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verificações de resultados esperados não devem (de preferências) ser abstraídos para custom commands.
Quero ler o arquivo de teste e entender o que ele faz sem precisar ler nenhum outro arquivo.

})