Skip to content

Commit 27ad6df

Browse files
committed
Added password generating method
1 parent e652009 commit 27ad6df

File tree

6 files changed

+78
-8
lines changed

6 files changed

+78
-8
lines changed

.vscode/launch.json

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Local File",
6+
"type": "Ruby",
7+
"request": "launch",
8+
"cwd": "${workspaceRoot}",
9+
"program": "${workspaceRoot}/main.rb"
10+
},
11+
{
12+
"name": "Listen for rdebug-ide",
13+
"type": "Ruby",
14+
"request": "attach",
15+
"cwd": "${workspaceRoot}",
16+
"remoteHost": "127.0.0.1",
17+
"remotePort": "1234",
18+
"remoteWorkspaceRoot": "${workspaceRoot}"
19+
},
20+
{
21+
"name": "Rails server",
22+
"type": "Ruby",
23+
"request": "launch",
24+
"cwd": "${workspaceRoot}",
25+
"program": "${workspaceRoot}/bin/rails",
26+
"args": [
27+
"server"
28+
]
29+
},
30+
{
31+
"name": "RSpec - all",
32+
"type": "Ruby",
33+
"request": "launch",
34+
"cwd": "${workspaceRoot}",
35+
"program": "${workspaceRoot}/bin/rspec",
36+
"args": [
37+
"-I",
38+
"${workspaceRoot}"
39+
]
40+
},
41+
{
42+
"name": "RSpec - active spec file only",
43+
"type": "Ruby",
44+
"request": "launch",
45+
"cwd": "${workspaceRoot}",
46+
"program": "${workspaceRoot}/bin/rspec",
47+
"args": [
48+
"-I",
49+
"${workspaceRoot}",
50+
"${file}"
51+
]
52+
},
53+
{
54+
"name": "Cucumber",
55+
"type": "Ruby",
56+
"request": "launch",
57+
"cwd": "${workspaceRoot}",
58+
"program": "${workspaceRoot}/bin/cucumber"
59+
}
60+
]
61+
}

Gemfile.lock

+5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ GEM
2121
mocha (1.2.1)
2222
metaclass (~> 0.0.1)
2323
mustermann (1.0.0)
24+
passgen (1.0.2)
2425
power_assert (1.0.2)
2526
rack (2.0.3)
2627
rack-protection (2.0.0)
2728
rack
29+
radcli (0.1.0)
30+
rake-compiler
2831
rake (12.0.0)
2932
rake-compiler (1.0.4)
3033
rake
@@ -44,6 +47,8 @@ PLATFORMS
4447

4548
DEPENDENCIES
4649
mocha
50+
passgen
51+
radcli
4752
rake
4853
rkerberos
4954
smart_proxy!

lib/smart_proxy_realm_ad/provider.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'proxy/kerberos'
2-
#require 'radcli'
2+
require 'radcli'
3+
require 'passgen'
34

45
module Proxy::AdRealm
56
class Provider
@@ -74,7 +75,7 @@ def do_host_create hostfqdn, password
7475

7576
def do_host_rebuild hostfqdn, password
7677
hostname = hostfqdn_to_hostname hostfqdn
77-
racli_password hostname, password
78+
radcli_password hostname, password
7879

7980
end
8081

@@ -103,7 +104,7 @@ def radcli_join hostfqdn, hostname, password
103104
end
104105

105106
def generate_password
106-
return "randompassword"
107+
Passgen::generate(:length => 20)
107108
end
108109

109110
def racli_password hostname, password

smart_proxy_realm_ad_plugin.gemspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ Gem::Specification.new do |s|
2020
s.add_development_dependency('mocha')
2121
s.add_development_dependency('test-unit')
2222
s.add_development_dependency('rkerberos')
23-
# s.add_development_dependency('radcli')
23+
s.add_development_dependency('passgen')
24+
s.add_development_dependency('radcli')
2425
end

test/ad_provider_test.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
require 'rubygems'
12
require 'test_helper'
23
require 'smart_proxy_realm_ad/provider'
4+
require 'radcli'
35

46
class RealmAdTest < Test::Unit::TestCase
57
def setup
68
@realm = 'test_realm'
7-
@provider = Proxy::AdRealm::Provider.new('test_realm', 'keytab_path', 'principal', 'domain-controller')
9+
@provider = Proxy::AdRealm::Provider.new('example.com', 'keytab_path', 'principal', 'domain-controller')
810
end
911

1012
def test_create_host
11-
hostname = 'hostname'
13+
hostname = 'host.example.com'
1214
password = 'a_password'
1315
params = {}
1416
params[:rebuild] = "false"
@@ -24,7 +26,7 @@ def test_create_with_unrecognized_realm_raises_exception
2426
end
2527

2628
def test_create_rebuild
27-
hostname = 'hostname'
29+
hostname = 'host.example.com'
2830
password = 'a_password'
2931
params = {}
3032
params[:rebuild] = "true"

test/api_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
curl -H "Accept: application/json" http://localhost:8000/features
55

66
# create host
7-
curl -d 'hostname=server1.example.com' http://localhost:8000/realm/EXAMPLE.COM
7+
curl -d 'hostname=server1.example.com' http://localhost:8000/:realm/:EXAMPLE.COM
88

99
# rebuild host
1010
curl -d 'hostname=server1.example.com&rebuild=true' http://localhost:8000/realm/EXAMPLE.COM

0 commit comments

Comments
 (0)