Skip to content
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
7 changes: 6 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:version: 0.0.2
:version: 0.0.3
:asciidoctor-base-version: 1.5.2
:confluence-version: 5.x

Expand Down Expand Up @@ -63,6 +63,11 @@ Here is the list of arguments that can used with this gem
|The password associated to the account used to login into Confluence
|

|bearerAuth
|no
|The Authorization Bearer token associated to the account used to login into Confluence
|

|update
|false
|Indicate that the page must be updated instead of created. No values are required for this option
Expand Down
4 changes: 4 additions & 0 deletions lib/asciidoctor/confluence/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def init_options(args)
opts.on('--password PASSWORD', 'the password used if credential are need to create the page') do |spaceKey|
self[:confluence][:auth][:password] = spaceKey
end

opts.on('--bearerAuth TOKEN', 'the token used if Bearer Authentication is required to create the page') do |token|
self[:confluence][:auth][:token] = token
end

opts.on_tail('-h', '--help', 'Show the full helper (including Asciidoctor helper)') do
$stdout.puts opts, "\n\n"
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/confluence/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Asciidoctor
module Confluence
VERSION = "0.0.2"
VERSION = "0.0.3"
end
end
11 changes: 10 additions & 1 deletion lib/asciidoctor/confluence_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ def create_connection
faraday.adapter Faraday.default_adapter
end

conn.basic_auth(@auth[:username], @auth[:password]) unless @auth.nil?
if @auth.nil?
return conn
end

if @auth[:token].nil?
conn.basic_auth(@auth[:username], @auth[:password])
else
conn.authorization :Bearer, @auth[:token]
conn.headers['Authorization']
end
conn
end

Expand Down
8 changes: 8 additions & 0 deletions test/Asciidoctor/confluence/options_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_init_options
assert_equal password, options[:confluence][:auth][:password]
end

def test_init_options_with_token
options = Asciidoctor::Confluence::Options.new
token = 'sometoken'
options.init_options ['--host', 'http://hostname', '--spaceKey', 'key', '--title', 'title', '--bearerAuth', token, 'file.adoc']

assert_equal token, options[:confluence][:auth][:token]
end

def test_with_full_options
args = {:confluence => {:host => 'http://hostname/', :space_key => 'TEST_KEY', :title =>'Test title'}}
options = Asciidoctor::Confluence::Options.new args
Expand Down