Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SSHCreateKey
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
AppleApps
rsyncOSX
SSHCreateKey
Commits
9f48c2d4
Commit
9f48c2d4
authored
8 months ago
by
Thomas Evensen
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
a5e5f727
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tests/SSHCreateKeyTests/ArgumentsCreatSSHKeys.swift
+43
-0
43 additions, 0 deletions
Tests/SSHCreateKeyTests/ArgumentsCreatSSHKeys.swift
Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift
+51
-88
51 additions, 88 deletions
Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift
with
94 additions
and
88 deletions
Tests/SSHCreateKeyTests/ArgumentsCreatSSHKeys.swift
0 → 100644
+
43
−
0
View file @
9f48c2d4
//
// ArgumentsCreatSSHKeys.swift
// SSHCreateKey
//
// Created by Thomas Evensen on 15/08/2024.
//
import
Foundation
struct
ArgumentsCreatSSHKeys
{
let
keypathglobal
=
"/Users/thomas/.ssh_global"
let
identityfileglobl
=
"global"
let
userHomeDirectoryPathglobal
=
"/Users/thomas"
let
sshkeypathandidentityfileglobal
=
"/Users/thomas/.ssh_global/global"
let
argumentssshcopyidglobal
=
"/usr/bin/ssh-copy-id -i ~/.ssh_global/global -p 2222 thomas@raspberrypi"
let
keypathdefault
=
"/Users/thomas/.ssh"
let
identityfiledefault
=
"id_rsa"
let
userHomeDirectoryPathdefault
=
"/Users/thomas"
let
sshkeypathandidentityfiledefault
=
"/Users/thomas/.ssh/id_rsa"
let
argumentssshcopyiddefault
=
"/usr/bin/ssh-copy-id -i /Users/thomas/.ssh/id_rsa thomas@raspberrypi"
/*
/Users/thomas/.ssh
id_rsa
/Users/thomas
/Users/thomas/.ssh/id_rsa
/usr/bin/ssh-copy-id -i /Users/thomas/.ssh/id_rsa thomas@raspberrypi
*/
/*
let arg3 = await sshcreatekey.keypathonly
print(arg3 ?? "")
let arg4 = await sshcreatekey.identityfile
print(arg4 ?? "")
let arg5 = await sshcreatekey.userHomeDirectoryPath
print(arg5 ?? "")
let arg6 = await sshcreatekey.sshkeypathandidentityfile
print(arg6 ?? "")
let arg7 = await sshcreatekey.argumentssshcopyid(offsiteServer: "raspberrypi", offsiteUsername: "thomas")
pri
*/
}
This diff is collapsed.
Click to expand it.
Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift
+
51
−
88
View file @
9f48c2d4
...
...
@@ -8,107 +8,70 @@ import Testing
let
loadtestdata
=
ReadTestdataFromGitHub
()
await
loadtestdata
.
getdata
()
testconfigurations
=
loadtestdata
.
testconfigurations
if
let
testconfigurations
{
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
TestSharedReference
.
shared
.
sshport
??
-
1
),
sharedsshkeypathandidentityfile
:
TestSharedReference
.
shared
.
sshkeypathandidentityfile
)
let
arg3
=
await
sshcreatekey
.
keypathonly
print
(
arg3
??
""
)
let
arg4
=
await
sshcreatekey
.
identityfile
print
(
arg4
??
""
)
let
arg5
=
await
sshcreatekey
.
userHomeDirectoryPath
print
(
arg5
??
""
)
let
arg6
=
await
sshcreatekey
.
sshkeypathandidentityfile
print
(
arg6
??
""
)
let
arg7
=
await
sshcreatekey
.
argumentssshcopyid
(
offsiteServer
:
"raspberrypi"
,
offsiteUsername
:
"thomas"
)
print
(
arg7
)
}
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
TestSharedReference
.
shared
.
sshport
??
-
1
),
sharedsshkeypathandidentityfile
:
TestSharedReference
.
shared
.
sshkeypathandidentityfile
)
let
arg3
=
await
sshcreatekey
.
keypathonly
#expect(ArgumentsCreatSSHKeys().keypathglobal == arg3)
let
arg4
=
await
sshcreatekey
.
identityfile
#expect(ArgumentsCreatSSHKeys().identityfileglobl == arg4)
let
arg5
=
await
sshcreatekey
.
userHomeDirectoryPath
#expect(ArgumentsCreatSSHKeys().userHomeDirectoryPathglobal == arg5)
let
arg6
=
await
sshcreatekey
.
sshkeypathandidentityfile
#expect(ArgumentsCreatSSHKeys().sshkeypathandidentityfileglobal == arg6)
let
arg7
=
await
sshcreatekey
.
argumentssshcopyid
(
offsiteServer
:
"raspberrypi"
,
offsiteUsername
:
"thomas"
)
#expect(ArgumentsCreatSSHKeys().argumentssshcopyidglobal == arg7)
}
@Test
func
LodaDataCreateSSHKeysdefault
()
async
{
let
loadtestdata
=
ReadTestdataFromGitHub
()
await
loadtestdata
.
getdata
()
testconfigurations
=
loadtestdata
.
testconfigurations
if
let
testconfigurations
{
let
port
=
-
1
let
identityfile
:
String
?
=
nil
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
port
),
sharedsshkeypathandidentityfile
:
identityfile
)
let
arg3
=
await
sshcreatekey
.
keypathonly
print
(
arg3
??
""
)
let
arg4
=
await
sshcreatekey
.
identityfile
print
(
arg4
??
""
)
let
arg5
=
await
sshcreatekey
.
userHomeDirectoryPath
print
(
arg5
??
""
)
let
arg6
=
await
sshcreatekey
.
sshkeypathandidentityfile
print
(
arg6
??
""
)
let
arg7
=
await
sshcreatekey
.
argumentssshcopyid
(
offsiteServer
:
"raspberrypi"
,
offsiteUsername
:
"thomas"
)
print
(
arg7
)
}
// Sett Shareddata to nil oe default values
let
port
=
-
1
let
identityfile
:
String
?
=
nil
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
port
),
sharedsshkeypathandidentityfile
:
identityfile
)
let
arg3
=
await
sshcreatekey
.
keypathonly
#expect(ArgumentsCreatSSHKeys().keypathdefault == arg3)
let
arg4
=
await
sshcreatekey
.
identityfile
#expect(ArgumentsCreatSSHKeys().identityfiledefault == arg4)
let
arg5
=
await
sshcreatekey
.
userHomeDirectoryPath
#expect(ArgumentsCreatSSHKeys().userHomeDirectoryPathdefault == arg5)
let
arg6
=
await
sshcreatekey
.
sshkeypathandidentityfile
#expect(ArgumentsCreatSSHKeys().sshkeypathandidentityfiledefault == arg6)
let
arg7
=
await
sshcreatekey
.
argumentssshcopyid
(
offsiteServer
:
"raspberrypi"
,
offsiteUsername
:
"thomas"
)
#expect(ArgumentsCreatSSHKeys().argumentssshcopyiddefault == arg7)
}
@Test
func
createkeys
()
async
{
let
loadtestdata
=
ReadTestdataFromGitHub
()
await
loadtestdata
.
getdata
()
testconfigurations
=
loadtestdata
.
testconfigurations
if
let
testconfigurations
{
do
{
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
TestSharedReference
.
shared
.
sshport
??
-
1
),
sharedsshkeypathandidentityfile
:
TestSharedReference
.
shared
.
sshkeypathandidentityfile
)
let
present
=
try
await
sshcreatekey
.
islocalpublicrsakeypresent
()
if
present
==
false
{
// If new keypath is set create it
let
sshrootpath
=
await
sshcreatekey
.
testcreatesshkeyrootpath
()
// Create keys
let
arguments
=
await
sshcreatekey
.
argumentscreatekey
()
let
command
=
"/usr/bin/ssh-keygen"
print
(
sshrootpath
??
""
)
print
(
command
)
print
(
arguments
?
.
joined
(
separator
:
" "
)
??
""
)
}
}
catch
let
e
{
let
error
=
e
print
(
error
)
}
}
}
@Test
func
createkeysdefault
()
async
{
let
loadtestdata
=
ReadTestdataFromGitHub
()
await
loadtestdata
.
getdata
()
testconfigurations
=
loadtestdata
.
testconfigurations
if
let
testconfigurations
{
do
{
let
port
=
-
1
let
identityfile
:
String
?
=
nil
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
port
),
sharedsshkeypathandidentityfile
:
identityfile
)
let
present
=
try
await
sshcreatekey
.
islocalpublicrsakeypresent
()
if
present
==
false
{
// If new keypath is set create it
let
sshrootpath
=
await
sshcreatekey
.
testcreatesshkeyrootpath
()
// Create keys
let
arguments
=
await
sshcreatekey
.
argumentscreatekey
()
let
command
=
"/usr/bin/ssh-keygen"
print
(
sshrootpath
??
""
)
print
(
command
)
print
(
arguments
?
.
joined
(
separator
:
" "
)
??
""
)
}
}
catch
let
e
{
let
error
=
e
print
(
error
)
}
}
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
TestSharedReference
.
shared
.
sshport
??
-
1
),
sharedsshkeypathandidentityfile
:
TestSharedReference
.
shared
.
sshkeypathandidentityfile
)
// If new keypath is set create it
let
sshrootpath
=
await
sshcreatekey
.
testcreatesshkeyrootpath
()
// Create keys
let
arguments
=
await
sshcreatekey
.
argumentscreatekey
()
print
(
sshrootpath
??
""
)
print
(
arguments
??
""
)
}
}
@Test
func
createkeysdefault
()
async
{
let
port
=
-
1
let
identityfile
:
String
?
=
nil
let
sshcreatekey
=
await
SSHCreateKey
(
sharedsshport
:
String
(
port
),
sharedsshkeypathandidentityfile
:
identityfile
)
let
sshrootpath
=
await
sshcreatekey
.
testcreatesshkeyrootpath
()
// Create keys
let
arguments
=
await
sshcreatekey
.
argumentscreatekey
()
print
(
sshrootpath
??
""
)
print
(
arguments
??
""
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment