Skip to content

Commit 5eea68a

Browse files
committed
send clientid with cookie
1 parent bdbd6f6 commit 5eea68a

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

src/cli/com/yetanalytics/datasim/cli/generate.clj

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
(def cookie-desc
6363
"An optional cookie string to send in the Cookie header.")
6464

65+
(def credential-id-desc
66+
"An optional credentialID parameter to send to the LRS.")
67+
6568
(def batch-size-desc
6669
"The batch size, i.e. how many statements to send at a time, for POSTing.")
6770

@@ -88,6 +91,9 @@
8891
[nil "--cookie COOKIE" "Authentication Cookie"
8992
:id :cookie
9093
:desc cookie-desc]
94+
[nil "--credential-id UUID" "Yet LRS Credential ID for use with cookie auth."
95+
:id :credential-id
96+
:desc credential-id-desc]
9197
["-B" "--batch-size SIZE" "LRS POST batch size"
9298
:id :batch-size
9399
:default 25
@@ -168,19 +174,21 @@
168174
password
169175
token
170176
cookie
177+
credential-id
171178
batch-size
172179
concurrency
173180
post-limit
174181
select-agents
175182
async]}
176183
options
177184
post-options
178-
{:endpoint endpoint
179-
:batch-size batch-size
180-
:username username
181-
:password password
182-
:token token
183-
:cookie cookie}]
185+
{:endpoint endpoint
186+
:batch-size batch-size
187+
:username username
188+
:password password
189+
:token token
190+
:cookie cookie
191+
:credential-id credential-id}]
184192
(if async
185193
(post-async! input post-options post-limit select-agents concurrency)
186194
(post-sync! input post-options post-limit select-agents))))

src/cli/com/yetanalytics/datasim/cli/input.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
(defn validate-input*
121121
"Perform validation on `input` and fail w/ early termination if
122122
it is not valid.
123-
123+
124124
When this is called, we should have valid individual inputs. However, there
125125
may be cross-validation that needs to happen, so we compose the
126126
comprehensive spec from the options and check that."

src/main/com/yetanalytics/datasim/client.clj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,20 @@
4646
[{:keys [username
4747
password
4848
token
49-
cookie]}]
50-
(cond
51-
(and username password)
52-
{:basic-auth [username password]}
53-
token
54-
{:headers {"Authorization" (format "Bearer %s" token)}}
55-
cookie
56-
{:headers {"Cookie" token}}
57-
:else {}))
49+
cookie
50+
credential-id]}]
51+
(let [opts (cond
52+
(and username password)
53+
{:basic-auth [username password]}
54+
token
55+
{:headers {"Authorization" (format "Bearer %s" token)}}
56+
cookie
57+
(cond-> {:headers {"Cookie" cookie}}
58+
credential-id
59+
(assoc :query-params {:credentialID credential-id}))
60+
:else {})]
61+
(println opts)
62+
opts))
5863

5964
(defn post-statements
6065
"Given LRS options and a `statement-seq`, send them to an LRS in synchronous

0 commit comments

Comments
 (0)