Skip to content

Commit

Permalink
Finish rest of verify tls implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Jan 28, 2024
1 parent 18929d9 commit 855e86c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
10 changes: 1 addition & 9 deletions database/factories/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

namespace Database\Factories;

use Convoy\Models\Location;
use Convoy\Models\Node;
use Illuminate\Database\Eloquent\Factories\Factory;

class NodeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Node::class;

/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'name' => $this->faker->word(),
'cluster' => 'proxmox',
'verify_tls' => true,
'fqdn' => $this->faker->word(),
'token_id' => $this->faker->word(),
'secret' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
Expand Down
27 changes: 18 additions & 9 deletions resources/scripts/components/admin/nodes/CreateNodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import useNodesSWR from '@/api/admin/nodes/useNodesSWR'
import FlashMessageRender from '@/components/elements/FlashMessageRenderer'
import MessageBox from '@/components/elements/MessageBox'
import Modal from '@/components/elements/Modal'
import CheckboxForm from '@/components/elements/forms/CheckboxForm'
import TextInputForm from '@/components/elements/forms/TextInputForm'

import LocationsSelectForm from '@/components/admin/nodes/LocationsSelectForm'


interface Props {
open: boolean
onClose: () => void
Expand All @@ -29,21 +31,22 @@ const CreateNodeModal = ({ open, onClose }: Props) => {
const { t } = useTranslation('admin.nodes.index')

const schema = z.object({
name: z.string().max(191).nonempty(),
name: z.string().min(1).max(191),
locationId: z.preprocess(Number, z.number()),
cluster: z.string().max(191).nonempty(),
tokenId: z.string().max(191).nonempty(),
secret: z.string().max(191).nonempty(),
fqdn: hostname().max(191).nonempty(),
cluster: z.string().min(1).max(191),
verifyTls: z.boolean(),
tokenId: z.string().min(1).max(191),
secret: z.string().min(1).max(191),
fqdn: hostname().min(1).max(191),
port: z.preprocess(Number, z.number().int().min(1).max(65535)),
memory: z.preprocess(Number, z.number().int().min(0)),
memoryOverallocate: z.preprocess(Number, z.number().int().min(0)),
disk: z.preprocess(Number, z.number().int().min(0)),
diskOverallocate: z.preprocess(Number, z.number().int().min(0)),
vmStorage: z.string().max(191).nonempty(),
backupStorage: z.string().max(191).nonempty(),
isoStorage: z.string().max(191).nonempty(),
network: z.string().max(191).nonempty(),
vmStorage: z.string().min(1).max(191),
backupStorage: z.string().min(1).max(191),
isoStorage: z.string().min(1).max(191),
network: z.string().min(1).max(191),
})

const form = useForm({
Expand All @@ -52,6 +55,7 @@ const CreateNodeModal = ({ open, onClose }: Props) => {
name: '',
locationId: '0',
cluster: '',
verifyTls: true,
tokenId: '',
secret: '',
fqdn: '',
Expand Down Expand Up @@ -132,6 +136,11 @@ const CreateNodeModal = ({ open, onClose }: Props) => {
<TextInputForm name='secret' label={t('secret')} />
</div>
<TextInputForm name='fqdn' label={tStrings('fqdn')} />
<CheckboxForm
name={'verifyTls'}
label='Verify TLS Certificate'
className={'mt-3 relative'}
/>
<TextInputForm name='port' label={tStrings('port')} />
<div className='grid gap-3 grid-cols-2'>
<TextInputForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useNodeSWR from '@/api/admin/nodes/useNodeSWR'
import Button from '@/components/elements/Button'
import FlashMessageRender from '@/components/elements/FlashMessageRenderer'
import FormCard from '@/components/elements/FormCard'
import CheckboxForm from '@/components/elements/forms/CheckboxForm'
import TextInputForm from '@/components/elements/forms/TextInputForm'

import LocationsSelectForm from '@/components/admin/nodes/LocationsSelectForm'
Expand All @@ -26,21 +27,22 @@ const NodeInformationCard = () => {
const { t: tIndex } = useTranslation('admin.nodes.index')

const schema = z.object({
name: z.string().max(191).nonempty(),
name: z.string().min(1).max(191),
locationId: z.preprocess(Number, z.number()),
cluster: z.string().max(191).nonempty(),
cluster: z.string().min(1).max(191),
verifyTls: z.boolean(),
tokenId: z.string().max(191),
secret: z.string().max(191),
fqdn: hostname().max(191).nonempty(),
fqdn: hostname().min(1).max(191),
port: z.preprocess(Number, z.number().int().min(1).max(65535)),
memory: z.preprocess(Number, z.number().int().min(0)),
memoryOverallocate: z.preprocess(Number, z.number().int().min(0)),
disk: z.preprocess(Number, z.number().int().min(0)),
diskOverallocate: z.preprocess(Number, z.number().int().min(0)),
vmStorage: z.string().max(191).nonempty(),
backupStorage: z.string().max(191).nonempty(),
isoStorage: z.string().max(191).nonempty(),
network: z.string().max(191).nonempty(),
vmStorage: z.string().min(1).max(191),
backupStorage: z.string().min(1).max(191),
isoStorage: z.string().min(1).max(191),
network: z.string().min(1).max(191),
})

const form = useForm({
Expand All @@ -49,6 +51,7 @@ const NodeInformationCard = () => {
name: node.name,
locationId: node.locationId.toString(),
cluster: node.cluster,
verifyTls: node.verifyTls,
tokenId: '',
secret: '',
fqdn: node.fqdn,
Expand Down Expand Up @@ -80,6 +83,7 @@ const NodeInformationCard = () => {
name: data.name,
locationId: data.locationId.toString(),
cluster: data.cluster,
verifyTls: data.verifyTls,
tokenId: '',
secret: '',
fqdn: data.fqdn,
Expand Down Expand Up @@ -121,6 +125,11 @@ const NodeInformationCard = () => {
name='fqdn'
label={tStrings('fqdn')}
/>
<CheckboxForm
name={'verifyTls'}
label='Verify TLS Certificate'
className={'relative'}
/>
<TextInputForm
name='port'
label={tStrings('port')}
Expand Down Expand Up @@ -209,4 +218,4 @@ const NodeInformationCard = () => {
)
}

export default NodeInformationCard
export default NodeInformationCard

0 comments on commit 855e86c

Please sign in to comment.