Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Add auth url (#29)
Browse files Browse the repository at this point in the history
co-authored-by: Sukaant Chaudhary <sukaant.chaudhary@gmail.com>

This is a breaking change.
Adding authUrl and authHeaders and renaming queryParams and headers to sourceQueryParams and sourceHeaders to avoid confusion.
  • Loading branch information
Austin committed Jun 12, 2019
1 parent da00092 commit bb16897
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
9 changes: 7 additions & 2 deletions lib/smart_city/dataset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ defmodule SmartCity.Dataset do
}
],
"sourceUrl": "",
"authUrl": "",
"sourceFormat": "",
"sourceType": "", // remote|stream|batch
"cadence": "",
"queryParams": {
"sourceQueryParams": {
"key1": "",
"key2": ""
},
"transformations": [], // ?
"validations": [], // ?
"headers": {
"sourceHeaders": {
"header1": "",
"header2": ""
}
"authHeaders": {
"header1": "",
"header2": ""
}
Expand Down
12 changes: 8 additions & 4 deletions lib/smart_city/dataset/technical.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ defmodule SmartCity.Dataset.Technical do
orgName: String.t(),
systemName: String.t(),
sourceUrl: String.t(),
authUrl: String.t(),
sourceFormat: String.t(),
schema: not_required(list(map())),
orgId: not_required(String.t()),
sourceType: not_required(String.t()),
cadence: not_required(String.t()),
queryParams: not_required(map()),
sourceQueryParams: not_required(map()),
transformations: not_required(list()),
validations: not_required(list()),
headers: not_required(map()),
sourceHeaders: not_required(map()),
authHeaders: not_required(map()),
partitioner: not_required(%{type: String.t(), query: String.t()}),
private: not_required(boolean())
}
Expand All @@ -28,16 +30,18 @@ defmodule SmartCity.Dataset.Technical do
defstruct cadence: "never",
credentials: false,
dataName: nil,
headers: %{},
sourceHeaders: %{},
authHeaders: %{},
orgId: nil,
orgName: nil,
partitioner: %{type: nil, query: nil},
private: true,
queryParams: %{},
sourceQueryParams: %{},
schema: [],
sourceFormat: nil,
sourceType: "remote",
sourceUrl: nil,
authUrl: nil,
systemName: nil,
transformations: [],
validations: []
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule SmartCity.Registry.MixProject do
def project do
[
app: :smart_city_registry,
version: "2.6.6",
version: "3.0.0",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
5 changes: 4 additions & 1 deletion test/support/fixture_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ defmodule FixtureHelper do
queryParams: %{},
transformations: ["a_transform"],
version: "1",
headers: %{
sourceHeaders: %{
Authorization: "Basic xdasdgdasgdsgd"
},
authHeaders: %{
afoo: "abar"
},
systemName: "scos",
orgName: "Whatever"
},
Expand Down
10 changes: 7 additions & 3 deletions test/unit/smart_city/dataset/technical_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ defmodule SmartCity.Dataset.TechnicalTest do
"sourceType" => "batch",
"cadence" => 30_000,
"sourceFormat" => "gtfs",
"headers" => %{
"sourceHeaders" => %{
"foo" => "bar"
},
"authHeaders" => %{
"afoo" => "abar"
},
"transformations" => [%{"foo" => %{"bar" => 1}}],
"validations" => [1, 2, 3]
}
Expand Down Expand Up @@ -42,14 +45,15 @@ defmodule SmartCity.Dataset.TechnicalTest do
test "returns Technical struct when given string keys", %{message: tech} do
actual = Technical.new(tech)
assert actual.systemName == "org__dataset"
assert actual.queryParams == %{}
assert actual.sourceQueryParams == %{}
assert actual.cadence == 30_000
assert actual.sourceType == "batch"
end

test "converts deeply nested string keys to atoms", %{message: tech} do
actual = Technical.new(tech)
assert actual.headers.foo == "bar"
assert actual.sourceHeaders.foo == "bar"
assert actual.authHeaders.afoo == "abar"
assert List.first(actual.transformations).foo.bar == 1
end

Expand Down
4 changes: 2 additions & 2 deletions test/unit/smart_city/dataset_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ defmodule SmartCity.DatasetTest do
"sourceFormat" => "gtfs",
"sourceType" => "stream",
"cadence" => 9000,
"headers" => %{},
"sourceHeaders" => %{},
"partitioner" => %{type: nil, query: nil},
"queryParams" => %{},
"sourceQueryParams" => %{},
"transformations" => [],
"validations" => [],
"schema" => []
Expand Down

0 comments on commit bb16897

Please sign in to comment.