1- // eslint-disable-next-line eslint-comments/disable-enable-pair
2- /* eslint-disable security/detect-non-literal-fs-filename */
1+ // eslint-disable-next-line @eslint-community/ eslint-comments/disable-enable-pair
2+ /* eslint-disable @typescript-eslint/no-magic-numbers, security/detect-non-literal-fs-filename, unicorn/prefer-string-raw */
33
44import assert from 'node:assert'
55import fs from 'node:fs/promises'
66import { describe , it } from 'node:test'
77
88import {
9+ type UncPath ,
910 type UncPathOptions ,
1011 connectToUncPath ,
1112 disconnectUncPath
@@ -45,17 +46,19 @@ await describe('windows-unc-path-connect', async () => {
4546} )
4647
4748await describe ( 'windows-unc-path-connect/validators' , async ( ) => {
48- await describe ( 'uncPathIsSafe()' , async ( ) => {
49- await it ( 'Returns "true" for good UNC paths' , async ( ) => {
50- const goodUncPaths = [ '\\\\192.168.1.1\\folder' ]
5149
50+ const goodUncPaths : UncPath [ ] = [ '\\\\192.168.1.1\\folder' ]
51+
52+ await describe ( 'uncPathIsSafe()' , async ( ) => {
53+ await it ( 'Returns "true" for good UNC paths' , ( ) => {
5254 for ( const goodUncPath of goodUncPaths ) {
5355 assert . strictEqual ( uncPathIsSafe ( goodUncPath ) , true )
5456 }
5557 } )
5658
57- await it ( 'Returns "false" for bad UNC paths' , async ( ) => {
59+ await it ( 'Returns "false" for bad UNC paths' , ( ) => {
5860 const badUncPaths = [
61+ // eslint-disable-next-line sonarjs/no-hardcoded-ip
5962 '192.168.1.1' , // missing slashes
6063 '\\192.168.1.1' , // missing double slash beginning
6164 '\\\\192.168.1.1\\folder" /delete' // includes double quote
@@ -68,40 +71,42 @@ await describe('windows-unc-path-connect/validators', async () => {
6871 } )
6972
7073 await describe ( 'uncPathOptionsHaveCredentials()' , async ( ) => {
71- await it ( 'Returns "true" for options with credentials' , async ( ) => {
74+ await it ( 'Returns "true" for options with credentials' , ( ) => {
7275 assert . strictEqual (
7376 uncPathOptionsHaveCredentials ( {
74- uncPath : '\\\\192.168.1.1\\folder' ,
77+ uncPath : goodUncPaths [ 0 ] ,
7578 userName : 'user' ,
79+ // eslint-disable-next-line sonarjs/no-hardcoded-credentials
7680 password : 'pass'
7781 } ) ,
7882 true
7983 )
8084 } )
8185
82- await it ( 'Returns "false" for options without credentials' , async ( ) => {
86+ await it ( 'Returns "false" for options without credentials' , ( ) => {
8387 const optionsWithoutCredentials : UncPathOptions [ ] = [
8488 {
85- uncPath : '\\\\192.168.1.1\\folder'
89+ uncPath : goodUncPaths [ 0 ]
8690 } ,
8791 {
88- uncPath : '\\\\192.168.1.1\\folder' ,
92+ uncPath : goodUncPaths [ 0 ] ,
8993 userName : ''
9094 } ,
9195 {
92- uncPath : '\\\\192.168.1.1\\folder' ,
96+ uncPath : goodUncPaths [ 0 ] ,
9397 userName : 'noPass'
9498 } ,
9599 {
96- uncPath : '\\\\192.168.1.1\\folder' ,
100+ uncPath : goodUncPaths [ 0 ] ,
97101 password : ''
98102 } ,
99103 {
100- uncPath : '\\\\192.168.1.1\\folder' ,
104+ uncPath : goodUncPaths [ 0 ] ,
105+ // eslint-disable-next-line sonarjs/no-hardcoded-credentials
101106 password : 'noUser'
102107 } ,
103108 {
104- uncPath : '\\\\192.168.1.1\\folder' ,
109+ uncPath : goodUncPaths [ 0 ] ,
105110 userName : '' ,
106111 password : ''
107112 }
0 commit comments